summaryrefslogtreecommitdiff
path: root/src/deck_convert.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/deck_convert.adb')
-rw-r--r--src/deck_convert.adb39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/deck_convert.adb b/src/deck_convert.adb
index 94b7098..a8c8673 100644
--- a/src/deck_convert.adb
+++ b/src/deck_convert.adb
@@ -26,11 +26,11 @@ procedure Deck_Convert is
package ACom renames Ada.Command_Line;
package GCom renames GNAT.Command_Line;
package GStr renames GNAT.Strings;
- package File renames Ada.Directories;
+ package FD renames Ada.Directories;
package SU renames Ada.Strings.Unbounded;
- use type File.File_Kind;
+ use type FD.File_Kind;
use type SU.Unbounded_String;
@@ -148,7 +148,7 @@ begin
return;
end if;
Input_Name := +(Input_Arg.all);
- if not File.Exists (-Input_Name) then
+ if not FD.Exists (-Input_Name) then
Put_Line (Standard_Error, "Input deck does not exist." &
Latin.LF & Further_Help);
ACom.Set_Exit_Status (ACom.Failure);
@@ -157,13 +157,13 @@ begin
if Output_Arg.all = "" then
- Put_Line (Standard_Error, "File name for output deck was not provided." &
+ Put_Line (Standard_Error, "Base file name for output deck was not provided." &
Latin.LF & Further_Help);
ACom.Set_Exit_Status (ACom.Failure);
return;
end if;
Output_Name := +(Output_Arg.all);
- if File.Exists ((-Output_Name) & "." & (-Deck_Format)) and not Overwrite then
+ if FD.Exists ((-Output_Name) & "." & (-Deck_Format)) and not Overwrite then
Put_Line (Standard_Error, "Output deck file name already exists." &
Latin.LF & Further_Help);
ACom.Set_Exit_Status (ACom.Failure);
@@ -171,14 +171,6 @@ begin
end if;
- -- if File.Exists ("collection.anki2") and not Overwrite then
- -- Put_Line (Standard_Error, "Temporary collection.anki2 file already exists." &
- -- Latin.LF & Further_Help);
- -- ACom.Set_Exit_Status (ACom.Failure);
- -- return;
- -- end if;
-
-
-- 1. extract media to a temporary file
-- 2. generate mapping of what media filenames correspond to what names in the zip
-- 3. extract collection.anki2 to a temporary file
@@ -204,14 +196,19 @@ begin
Deck_IO.Query_Notes (Deck, Notes);
Deck_IO.Close_Database (Deck);
- if Deck_Format = "csv" then
- Deck_IO.Write_CSV ("", "", Models, Notes);
- elsif Deck_Format = "fmd" then
- Deck_IO.Read_Media_Map (-Input_Name, Media);
- Deck_IO.Write_FMD ("", "", Models, Notes, Media);
- else
- raise Constraint_Error;
- end if;
+ declare
+ Contain_Dir : String := FD.Containing_Directory (-Output_Name);
+ Simple_Name : String := FD.Simple_Name (-Output_Name);
+ begin
+ if Deck_Format = "csv" then
+ Deck_IO.Write_CSV (Contain_Dir, Simple_Name, Models, Notes, Overwrite);
+ elsif Deck_Format = "fmd" then
+ Deck_IO.Read_Media_Map (-Input_Name, Media);
+ Deck_IO.Write_FMD (Contain_Dir, Simple_Name, Models, Notes, Media, Overwrite);
+ else
+ raise Constraint_Error;
+ end if;
+ end;
end Deck_Convert;