1. opening files with spaces in pathname?
- Posted by DanM Mar 04, 2009
- 870 views
I seem to not be able to cause a file to open because of having spaces in the files pathname, and I think I remember that there is some way to work around this. Is there such a trick, and if so, what is it?
Dan
2. Re: opening files with spaces in pathname?
- Posted by jeremy (admin) Mar 04, 2009
- 867 views
Dan,
Can you give us an example? I just tried:
? open("hello world how are you doing.txt", "r")
and it opened the file just fine. Further, read_file("...") read the file w/o issue.
Jeremy
3. Re: opening files with spaces in pathname?
- Posted by ghaberek (admin) Mar 04, 2009
- 820 views
Windows (exw, exwc) and Linux/FreeBSD (exu) should handle spaces correctly. However, DOS (ex) will probably fail on spaces. Are you using ex when you should be using exwc instead?
-Greg
4. Re: opening files with spaces in pathname?
- Posted by jeremy (admin) Mar 04, 2009
- 856 views
Windows (exw, exwc) and Linux/FreeBSD (exu) should handle spaces correctly. However, DOS (ex) will probably fail on spaces. Are you using ex when you should be using exwc instead?
Oh! Good point, I didn't even think of that. I was using exwc in my example.
Jeremy
5. Re: opening files with spaces in pathname?
- Posted by DanM Mar 04, 2009
- 880 views
Dan,
Can you give us an example? I just tried:
? open("hello world how are you doing.txt", "r")
and it opened the file just fine. Further, read_file("...") read the file w/o issue.
Jeremy
It's the PATHNAME (path + filename) that has spaces in some of the FOLDER'S NAMES that I think is making the file not open.
Dan
6. Re: opening files with spaces in pathname?
- Posted by ghaberek (admin) Mar 04, 2009
- 883 views
It's the PATHNAME (path + filename) that has spaces in some of the FOLDER'S NAMES that I think is making the file not open.
Or are you just not concatenating the string properly?
constant PATH = "C:\\Program Files\\Application" constant FILE = "filename.txt" sequence NAME = PATH & '\\' & FILE -- note the separating backslash
-Greg
7. Re: opening files with spaces in pathname?
- Posted by DanM Mar 04, 2009
- 896 views
It's the PATHNAME (path + filename) that has spaces in some of the FOLDER'S NAMES that I think is making the file not open.
Or are you just not concatenating the string properly?
constant PATH = "C:\\Program Files\\Application" constant FILE = "filename.txt" sequence NAME = PATH & '\\' & FILE -- note the separating backslash
-Greg
Good question..I'm not sure, but I don't think so,
as I'm getting the path & file name from
Win32Lib dialog, "getOpenFileName":
setCurrentDirectory ("C:\\Programming\\EUPHORIA\\Programs Under Development\\FromIde\\VCRdataBase") fileName = getOpenFileName( Window1, -- parent window "", -- no default name { "Monthly TV Episodes", "*.mon", -- data files "All Files", "*.*" } ) -- everything else if length( fileName ) = 0 then setText({aStatus,1},"No File Selected") return end if puts(1, "\nthe filename: " & fileName) -- open the file handle = open( fileName, "r" ) while 1 do -- get data data = gets(handle) -- end of file? if atom(data) then exit end if end while puts(1, "\nthe monthly data:\n") pretty_print(1, data, {2}) close(handle)
and my debug reports read:
the filename: C:\Programming\EUPHORIA\Programs Under Development\FromIde\VCRdat aBase\HouseTvMar.mon
the monthly data: -1
Dan
8. Re: opening files with spaces in pathname?
- Posted by DanM Mar 04, 2009
- 854 views
It's the PATHNAME (path + filename) that has spaces in some of the FOLDER'S NAMES that I think is making the file not open.
Or are you just not concatenating the string properly?
constant PATH = "C:\\Program Files\\Application" constant FILE = "filename.txt" sequence NAME = PATH & '\\' & FILE -- note the separating backslash
-Greg
Good question..I'm not sure, but I don't think so,
as I'm getting the path & file name from
Win32Lib dialog, "getOpenFileName":
setCurrentDirectory ("C:\\Programming\\EUPHORIA\\Programs Under Development\\FromIde\\VCRdataBase") fileName = getOpenFileName( Window1, -- parent window "", -- no default name { "Monthly TV Episodes", "*.mon", -- data files "All Files", "*.*" } ) -- everything else if length( fileName ) = 0 then setText({aStatus,1},"No File Selected") return end if puts(1, "\nthe filename: " & fileName) -- open the file handle = open( fileName, "r" ) while 1 do -- get data data = gets(handle) -- end of file? if atom(data) then exit end if end while puts(1, "\nthe monthly data:\n") pretty_print(1, data, {2}) close(handle)
and my debug reports read:
the filename: C:\Programming\EUPHORIA\Programs Under Development\FromIde\VCRdat aBase\HouseTvMar.mon
the monthly data: -1
Dan
9. Re: opening files with spaces in pathname?
- Posted by DanM Mar 04, 2009
- 870 views
arrghh! sorry 'bout the double post, hit post instead of preview!
I meant to repair the filename, as it didn't show here as it actually presented in debug, here's what it reports, with 3 words separated by two spaces in one folder, and NO space in the LAST folder in the path:
the filename: C:\Programming\EUPHORIA\Programs Under Development\FromIde\VCRdataBase\HouseTvMar.mon
the monthly data: -1
Dan [/quote]
10. Re: opening files with spaces in pathname?
- Posted by DanM Mar 04, 2009
- 794 views
I seem to not be able to cause a file to open because of having spaces in the files pathname, and I think I remember that there is some way to work around this. Is there such a trick, and if so, what is it?
Dan
jeeze, another silly mistake, plus the power of a wrong assumption: it wasn't a problem with spaces in the path AT ALL, it was that I was reading the file WRONGLY (was reading a line at a time, but then didn't notice that it needed to concatenate the lines).
sigh, nevermind, sorry 'bout that.
Dan
11. Re: opening files with spaces in pathname?
- Posted by jeremy (admin) Mar 04, 2009
- 793 views
If I had a penny for every time I made a similar mistake, I'd be retired
Jeremy