1. opening files with spaces in pathname?

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

new topic     » topic index » view message » categorize

2. Re: opening files with spaces in pathname?

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: opening files with spaces in pathname?

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: opening files with spaces in pathname?

ghaberek said...

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: opening files with spaces in pathname?

jeremy said...

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

new topic     » goto parent     » topic index » view message » categorize

6. Re: opening files with spaces in pathname?

DanM said...

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

new topic     » goto parent     » topic index » view message » categorize

7. Re: opening files with spaces in pathname?

ghaberek said...
DanM said...

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

new topic     » goto parent     » topic index » view message » categorize

8. Re: opening files with spaces in pathname?

DanM said...
ghaberek said...
DanM said...

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

new topic     » goto parent     » topic index » view message » categorize

9. Re: opening files with spaces in pathname?

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]

new topic     » goto parent     » topic index » view message » categorize

10. Re: opening files with spaces in pathname?

DanM said...

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). sad

sigh, nevermind, sorry 'bout that.

Dan

new topic     » goto parent     » topic index » view message » categorize

11. Re: opening files with spaces in pathname?

If I had a penny for every time I made a similar mistake, I'd be retired smile

Jeremy

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu