progress with conversion functionality
This commit is contained in:
@@ -73,4 +73,6 @@ imperative-shell/file-thread.sml
|
|||||||
imperative-shell/draw-thread.sml
|
imperative-shell/draw-thread.sml
|
||||||
imperative-shell/init-glfw.sml
|
imperative-shell/init-glfw.sml
|
||||||
|
|
||||||
|
imperative-shell/converter.sml
|
||||||
|
|
||||||
imperative-shell/shell.sml
|
imperative-shell/shell.sml
|
||||||
|
|||||||
45
imperative-shell/converter.sml
Normal file
45
imperative-shell/converter.sml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
structure Converter =
|
||||||
|
struct
|
||||||
|
fun endsWithDsc str =
|
||||||
|
if String.size str >= 4 then
|
||||||
|
let
|
||||||
|
val size = String.size str
|
||||||
|
val expectedExtension = String.substring (str, size - 4, 4)
|
||||||
|
in
|
||||||
|
expectedExtension = ".dsc"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
false
|
||||||
|
|
||||||
|
fun convertFile path = ()
|
||||||
|
|
||||||
|
fun loop (dir, rootPath) =
|
||||||
|
case OS.FileSys.readDir dir of
|
||||||
|
SOME path =>
|
||||||
|
let
|
||||||
|
val folderPath = String.concat [rootPath, "/", path]
|
||||||
|
in
|
||||||
|
if OS.FileSys.isDir folderPath then
|
||||||
|
(* handle folder *)
|
||||||
|
let val newDir = OS.fileSys.openDir folderPath
|
||||||
|
in loop (newDir, folderPath)
|
||||||
|
end
|
||||||
|
else if OS.FileSys.isLink folderPath then
|
||||||
|
(* continue looping and ignore *)
|
||||||
|
loop (dir, rootPath)
|
||||||
|
else
|
||||||
|
(* handle file, if file has ".dsc" at the end *)
|
||||||
|
let val () = if endsWithDsc path then convertFile folderPath else ()
|
||||||
|
in loop (dir, rootPath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
| NONE => OS.FileSys.closeDir dir
|
||||||
|
|
||||||
|
fun main () =
|
||||||
|
let
|
||||||
|
val path = OS.FileSys.getDir ()
|
||||||
|
val dir = OS.FileSys.openDir path
|
||||||
|
in
|
||||||
|
loop (dir, path)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -2,7 +2,7 @@ structure Shell =
|
|||||||
struct
|
struct
|
||||||
fun main () =
|
fun main () =
|
||||||
case CommandLine.arguments () of
|
case CommandLine.arguments () of
|
||||||
["-r"] => (print "todo: convert dsc files to sml file\n")
|
["-r"] => Converter.main ()
|
||||||
| [] => InitGlfw.main ()
|
| [] => InitGlfw.main ()
|
||||||
| args =>
|
| args =>
|
||||||
let
|
let
|
||||||
|
|||||||
Reference in New Issue
Block a user