Is there a way to test for the difference between a file or directory?
I have tried the following two functions, but both return true for files and directories...
DOESDIREXIST
DOESFILEEXIST
Hi Bugtunacan, take a look to this code, you can find in the help searching GETFILELIST() command
With the Orange part I think you have enough for your Code.
// --------------------------------- //
// Project: Files and Folders
// Start: Tuesday, November 25, 2003
// IDE Version: 1.31125
LOADFONT "minifont.bmp", 0
GETFONTSIZE font_x, font_y
[color=orange] ok = SETCURRENTDIR("..") // One up
cur$ = GETCURRENTDIR$()
num = GETFILELIST("*.*", files$[])
num_dir = INTEGER(num / 0x10000) // Hi-Word
num_file = MOD(num, 0x10000) // Lo-Word
[/color]
PRINT cur$, 0, 0
PRINT "ok? " + ok+ " num: " + num + " -> nDir: "+num_dir+" nFile: "+num_file, 0, font_y
FOR i=0 TO BOUNDS(files$[], 0)-1 // BOUNDS(files$[], 0)-1 = num = num_dir+num_file
PRINT files$[i], 0, (i+3)*font_y
NEXT
SHOWSCREEN
MOUSEWAIT
Do you uses the newest glbasic? Else this might been a strange bug, which should not been happens.
Alternative, you could test the file by trying to open the file, if its exists.If you cant open the file, then its would been a directory....
If it's true, its a bug. What platform?
Windows 7 works for me at least, here is my testcode:
LOCAL ok%, file$
file$ = "C:/temp/"
ok% = DOESDIREXIST(file$)
IF ok% = TRUE
DEBUG "\n Is dir: " + file$
ELSE
DEBUG "\n No dir: " + file$
ENDIF
ok% = DOESFILEEXIST(file$)
IF ok% = TRUE
DEBUG "\n Is file: " + file$
ELSE
DEBUG "\n No file: " + file$
ENDIF
file$ = "C:/temp/test.txt"
ok% = DOESDIREXIST(file$)
IF ok% = TRUE
DEBUG "\n Is dir: " + file$
ELSE
DEBUG "\n No dir: " + file$
ENDIF
ok% = DOESFILEEXIST(file$)
IF ok% = TRUE
DEBUG "\n Is file: " + file$
ELSE
DEBUG "\n No file: " + file$
ENDIF
Is dir: C:/temp/
No file: C:/temp/
No dir: C:/temp/test.txt
Is file: C:/temp/test.txt