Read Dir and filename and pack it?
BlitzMax Forums/BlitzMax Programming/Read Dir and filename and pack it?
| ||
How can it write each file and files inside directory and write directory name and would I do it from directory instead of using a list file.stream$="cfg1/app.txt" If Asc(stream$) Then CreateDir(UnpackDir$+stream$) files.txt 2 test.txt config\settings.txt test.txt Testing... config\settings.txt Height = 800 Width = 600 Depth = 32 Mode = 2 Packer.bb Unpacker.bmx |
| ||
| Guys, I relly need help to detect directory or file from string. like data\config.bin settings.cfg |
| ||
| Hi, in Blitzmax you could do it in something like this: Strict
Local s:String = "data\config.bin"
Local ar:String[] = s.Replace("/", "\").split("\")
If Not ar Then Print "String was empty"; End 'Always good to check before accessing objects
If ar.length > 1 Then
Print "There are folders!"
For Local i:Int = 0 Until ar.length - 1 'Everything else, but not the last, as that is a file
Print "Folder: " + ar[i]
Next
Print "File: " + ar[ ar.length - 1 ]
Else
'No folders, just file
Print "File: " + ar[0]
EndIfThere are many ways, this is just one. -Henri |