Win32:RequestFile and RequestDir
BlitzMax Forums/BlitzMax Programming/Win32:RequestFile and RequestDir
| ||
On win32 systems both RequestFile and RequestDir return directory paths with backslashes "\" instead of forward slashes "/" like all the other file and directory functions.' requestfile.bmx filter$="Image Files:png,jpg,bmp;Text Files:txt;All Files:*" filename$=RequestFile( "Select graphic file to open",filter$ ) Print filenameHaving a quick look at the source I think this can be solved by a call to FixPath. |
| ||
Hi, You can legally use either / or \ in paths on the win32 platform so not sure if this is a 'bug'. |
| ||
That is true but if I'm comparing a string returned from the function CurrentDir and a string returned from RequestDir they will always be different unless I convert all the slashes in one of them. I just expected all the file functions to return paths that use the same convention. |
| ||
Good point. Thinking... |
| ||
What about a 'file comparison' function (getting two string as parameters, with a comparable filenames. This function could process all the / and \ and even all the ..\ and .\ to get a simple path of each file, even convert the strings to lowercase or uppercase on win and mac, before comparing them, and return true or false if the given strings are 'pointing' to the same file). Can this could be a good solution for this platform releated issue? |
| ||
What about a 'file comparison' function (getting two string as parameters, with a comparable filenames. This function could process all the / and \ and even all the ..\ and .\ to get a simple path of each file, even convert the strings to lowercase or uppercase on win and mac, before comparing them, and return true or false if the given strings are 'pointing' to the same file). Well, there's already 'RealPath' in there which does most of this - eg: RealPath(x)=RealPath(y). This could easily be wrapped in a ComparePaths(). I think this RealPath/ComparePaths approach is probably the safest, instead of trying to coerce all file names at 'source' into a common format. This means it wont matter if the path is win32/unix/absolute/relative or whatever. I will have a closer look at RealPath() and make sure it's up to the job! |