Relative Paths

The official forum for ZSNES documentation. Discuss future changes, mistakes, etc...
You can also join us on IRC at irc.freenode.net in #zsnes-docs.

Moderators: ZSNES Mods, ZSNES Doc Team

Post Reply
Pure Pandemonium
New Member
Posts: 4
Joined: Fri Apr 13, 2007 3:06 am

Relative Paths

Post by Pure Pandemonium »

Suggestion: An example of how to use relative paths to put save files and such into a local saves directory.
e.g. .\saves

Maybe I just missed something obvious, but I was having trouble making ZSNES put my save files into a directory other than where my roms are stores. I got a mysterious could not save error if I had \saves\ or saves\ as my path.

In docs right now are relative (..\..\saves) or absolute (c:\zsnes\saves)

It took me a while digging through the forums to find a link to wikipedia to remedy my problem. A single period. Gah. An extra line or two to make things clearer might be nice.
Jipcy
Veteran
Posts: 768
Joined: Thu Feb 03, 2005 8:18 pm
Contact:

Post by Jipcy »

Nach and/or anyone who knows, do relative paths work as expected with ZSNES these days? I thing I remember a while ago they didn't work in all conditions.

And someone remind me, what does one dot do? Two dots are up one folder, right?
[url=http://zsnes-docs.sf.net]Official ZSNES Docs[/url] | [url=http://zsnes-docs.sf.net/nsrt]NSRT Guide[/url] | [url=http://endoftransmission.net/phpBB3/viewtopic.php?t=394]Using a Wiimote w/ emulators[/url]
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Relative paths work to my knowledge.

. == current dir
.. == up one dir
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

I believe current SVN has every kind of path even relative working properly now. Although I haven't tested Windows myself. I'll test Windows a bit later to make sure no Windows stupidity is screwing up my beloved path system.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Pure Pandemonium
New Member
Posts: 4
Joined: Fri Apr 13, 2007 3:06 am

Post by Pure Pandemonium »

They work fine, if you know what to do.

It's just not well documented how to do something common like saving to a directory next to zsnes.exe instead of dumping files with the roms.

One dot is current directory. No dots does nothing, and gives a vague error message when you try to save.
Ichinisan
Veteran
Posts: 603
Joined: Wed Jul 28, 2004 8:54 am

Post by Ichinisan »

Pure Pandemonium wrote:They work fine , if you know what to do.

It's just not well documented how to do something common like saving to a directory next to zsnes.exe instead of dumping files with the roms.

One dot is current directory. No dots does nothing , and gives a vague error message when you try to save.
I haven't tested , but if relative paths are *properly* implemented , "\SAVE" should go to a "SAVE" folder located directly on the root of the current drive (wherever ZSNES was executed from). It should not give you an error message unless the folder does not exist or is inaccessible. I wouldn't expect that message to be "vague", though I'll have to try it and see what it actually says. If it does give an error, and the folder exists and is accessible, then relative paths are not properly implemented. The initial slash is synonymous with "root directory". This is why CD \SAVES\ will switch to that folder from the command line no matter which folder is currently occupied (as long as the current drive is the correct one). This is not specific to windows. It's not only a Windows thing either. CD / works to go to the root of an FTP , indicating that UNIX and other systems equate a starting slash to mean "root". I tested the command-line FTP client with Windows XP:

[Win]+[R] , cmd , [ENTER]
ftp ftp.mozilla.org , [ENTER]
anonymous , [ENTER] (username)
[ENTER] (blank password)
cd pub/mozilla.org/firefox/releases/latest/win32/en-US , [ENTER]
ls , [ENTER]
get "Firefox Setup 2.0.0.3.exe" , [ENTER] (closing quote not actually required)
cd /pub/mozilla.org/thunderbird/releases/latest/win32/en-US , [ENTER] - Did anyone see what I just did there? ;)
ls , [ENTER]
get "Thunderbird Setup 1.5.0.10.exe" , [ENTER] (Again the closing quote is not actually required)
bye , [ENTER]
start . , [ENTER]
exit , [ENTER]

Works like a charm...

The root slash work great in HTML also:

Code: Select all

<HTML>
<A HREF="/images/fullscreen/penis.jpg">
<IMG SRC="/images/thumbnails/kittens.jpg">
<BR>Click for wallpaper-size image!
</A>
</HTML>
Both of these examples use Unix style paths, but it's the same principle for local paths on Windows, only with a "" for local paths instead of a "/".

[edit]
Slightly edit'd
Last edited by Ichinisan on Sun Apr 15, 2007 2:07 am, edited 2 times in total.
Need a new sig...
Pure Pandemonium
New Member
Posts: 4
Joined: Fri Apr 13, 2007 3:06 am

Post by Pure Pandemonium »

Thank you for the research and in-depth reply.

I vaguely remember not having hassles with this with on an earlier version of ZSNES, but I wasn't confident enough to report it as a bug, and didn't think to test an earlier release.


Looks like it's been broken (in windows, at least). \SAVE\ works fine on 1.42, and gives an Unable To Save message on 1.50 and 1.51.
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

relative paths do not start with a \ or a /
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

funkyass wrote:relative paths do not start with a \ or a /
We have a winner.
Pure Pandemonium wrote:Thank you for the research and in-depth reply.

I vaguely remember not having hassles with this with on an earlier version of ZSNES, but I wasn't confident enough to report it as a bug, and didn't think to test an earlier release.


Looks like it's been broken (in windows, at least). \SAVE\ works fine on 1.42, and gives an Unable To Save message on 1.50 and 1.51.
That's because that 1.42 paths is more broken than you think and that you are misunderstanding relative paths.

"\SAVES" does mean root path (generally C:) attached to the listed path (in other words, that is translated into C:\SAVES in this instance).
Last edited by Deathlike2 on Sun Apr 15, 2007 1:30 am, edited 4 times in total.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

If you're getting unable to save message with a path of "\save", then I doubt you have a directory called "save" in the root of your current drive with write permission.

If you wanted a relative path for save in the current directory you want one of these four:
save
save\
.\save
.\save\
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Ichinisan
Veteran
Posts: 603
Joined: Wed Jul 28, 2004 8:54 am

Post by Ichinisan »

funkyass, All: A path beginning with a slash *is* "relative". It is relative to the drive that you are working from and not the directory.

Yup. 8)
Need a new sig...
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Ichinisan wrote:funkyass, All: A path beginning with a slash *is* "relative".
Incorrect.

It may only be correct when quantified with there being multiple root directories.

However even on a system like DOS or Windows which has multiple root directories, many would deem the root path to be absolute irregardless of the fact that there are drives.

Relative Path is defined thus: "A relative path is a path relative to the current working directory". On DOS/Windows since there are multiple working directories, you figure it out. The topic in this instance is debatable at best.

Furthermore, a user is wondering why .\save works and not \save, surely even you can tell the difference.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
Pure Pandemonium
New Member
Posts: 4
Joined: Fri Apr 13, 2007 3:06 am

Post by Pure Pandemonium »

Nach wrote:If you're getting unable to save message with a path of "\save", then I doubt you have a directory called "save" in the root of your current drive with write permission.

If you wanted a relative path for save in the current directory you want one of these four:
save
save\
.\save
.\save\
OK. "\save" does write to a "c:\save" folder if I make one. But "save" fails to do anything as far as I can tell.

I can't try "save" nor ".\save" as ZSNES adds a trailing slash.

Whichever way the program works, I suggest the docs help explain how to put save files into a directory next to the exe.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Pure Pandemonium wrote:
Nach wrote:If you're getting unable to save message with a path of "\save", then I doubt you have a directory called "save" in the root of your current drive with write permission.

If you wanted a relative path for save in the current directory you want one of these four:
save
save\
.\save
.\save\
OK. "\save" does write to a "c:\save" folder if I make one. But "save" fails to do anything as far as I can tell.[/qu

I can't try "save" nor ".\save" as ZSNES adds a trailing slash.

Whichever way the program works, I suggest the docs help explain how to put save files into a directory next to the exe.
That's probably because you didn't create the folder first.

Besides, that's not as useful to explain it, as you need to know how relative paths work before attempting it in the first place.

Also, make sure to hit the enter/return key when done entering the path. This is the most important step.

Just in case you are still not clued in, "save" or ".\save" implies "(ZSNES executable location)\Save". I've already tested it.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

Pure Pandemonium wrote: I can't try "save" nor ".\save" as ZSNES adds a trailing slash.
You did just try it. As you found out, ZSNES converts it, so "save" == "save".

In any event, you want to make sure you created the path you entered.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
CZroe
Rookie
Posts: 23
Joined: Fri Jan 13, 2006 7:01 pm

Post by CZroe »

Nach wrote:
Ichinisan wrote:funkyass, All: A path beginning with a slash *is* "relative".
Incorrect.

It may only be correct when quantified with there being multiple root directories.

However even on a system like DOS or Windows which has multiple root directories, many would deem the root path to be absolute irregardless of the fact that there are drives.

Relative Path is defined thus: "A relative path is a path relative to the current working directory". On DOS/Windows since there are multiple working directories, you figure it out. The topic in this instance is debatable at best.

Furthermore, a user is wondering why .\save works and not \save, surely even you can tell the difference.
Oh it is indeed relative. You could argue that it is relative to the drive and not the directory, but the drive is also relative to the directory and you are telling the commandline to switch to the drive root that is relative to the current directory. If you were in "C:\Program Files\Microsoft\." and you wanted to switch to "C:\DOWNLOAD\SNES\." , You could do it by typing "CD\DOWNLOAD\SNES" and hitting ENTER. If you were working on a different drive and you wanted to change the working directory of C:\, you would have to use a full path (the command prompt will stay the same until you switch drives when you will then see that it did indeed change working directories on the other drive).

Once again, though "" is relative to the drive root, it is also relative to the current working directory because the directory is also relative to the drive.
McAffee says ZSNES has a virus in it!*nt*
im glad u think its funny a**hole o wate no im not go 2 hell
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

"\" isn't relative to anything - its a character that's used to define directories in a file path - its also the general synonym for a file system's root directory when used either by itself or at the start of a local file path.

its better to think of a relative path as one that starts with the current working directory in transversing the file system. Microsoft throws a wrench into this with its drive letters, as there OS's lack the concept of a single root for file systems - so a file on a: will never be relative to a file on c:, since they don't share a common root.
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.
CZroe
Rookie
Posts: 23
Joined: Fri Jan 13, 2006 7:01 pm

Post by CZroe »

funkyass wrote:"" isn't relative to anything - its a character that's used to define directories in a file path - its also the general synonym for a file system's root directory when used either by itself or at the start of a local file path.

its better to think of a relative path as one that starts with the current working directory in transversing the file system. Microsoft throws a wrench into this with its drive letters, as there OS's lack the concept of a single root for file systems - so a file on a: will never be relative to a file on c:, since they don't share a common root.
Yes it is relative to something; no it isn't simply used to define directories in a path. "CD" will always take you to the root of the drive you are working with. The drive you are working with is relative. The "" between directory names it more than a seperator: It denotes the root of each directory. If I wanted my program to dump a log on the root of whatever drive it was executed from, telling it to write the file to the "" directory would do the trick. No need to specify drive letters that may not be the same across different systems. It's relative to the path executed from, so it's relative.
McAffee says ZSNES has a virus in it!*nt*
im glad u think its funny a**hole o wate no im not go 2 hell
funkyass
"God"
Posts: 1128
Joined: Tue Jul 27, 2004 11:24 pm

Post by funkyass »

did you read the second paragraph?
Does [Kevin] Smith masturbate with steel wool too?

- Yes, but don’t change the subject.
Noxious Ninja
Dark Wind
Posts: 1271
Joined: Thu Jul 29, 2004 8:58 pm
Location: Texas
Contact:

Post by Noxious Ninja »

funkyass wrote:its better to think of a relative path as one that starts with the current working directory in transversing the file system. Microsoft throws a wrench into this with its drive letters, as there OS's lack the concept of a single root for file systems - so a file on a: will never be relative to a file on c:, since they don't share a common root.
Windows (2000 and later, AFAIK) actually does have mount points of some sort. I've never tried them, but supposedly you actually could have everything under C:\.
[u][url=http://bash.org/?577451]#577451[/url][/u]
henke37
Lurker
Posts: 152
Joined: Tue Apr 10, 2007 4:30 pm
Location: Sweden
Contact:

Post by henke37 »

What he means is that windows nt+ can mount volumes in directories just like posix can.

Also, I think that relative path must be explicitly defined from where they are relative. As in the docs must say what folder "." is for the paths, the cd of the invokement(or as set in the shortcut files on windows), the place of the rom file, the zsnes installpath(possibly different from invocation dir) or the user's home dir.
adam0509
New Member
Posts: 7
Joined: Mon Dec 25, 2006 12:35 am

Post by adam0509 »

hi allz !

I was using Windows for a while, but now I use Ubuntu Linux...


I got all my save in the same directory as my roms :
gedit zsnesl.cfg wrote: ; ROMs directory
ROMPath="/media/sda4/Jeux - emulation/nintendo_snes/roms/Mr Nutz/"
Folder "Mr Nutz" contains "Mrnutz.smc", "Mrnutrz.zs1", etc...
; Save states & SRAMs, snapshots, SPCs
SRAMPath="./"
SnapPath="./"
SPCPath="./"
I tryed "." "/" "" "save" "." "./" " " for SRAMPath="./" but nothing works !! I can't see my saves... :/

Thank U in advance !!
Post Reply