forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[PS2] New basename and dirname implementations for ps2sdk

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> Patch Submissions
View previous topic :: View next topic  
Author Message
ragnarok2040



Joined: 09 Aug 2006
Posts: 230

PostPosted: Thu Jul 22, 2010 10:25 am    Post subject: [PS2] New basename and dirname implementations for ps2sdk Reply with quote

I guess I only scratched the surface when I did these before, but now they work pretty well. I made them more PS2-specific so it treats device specifiers/mount points as directories, works with slashes at the end of the path, multiple slashes, and such. It also works with standard Unix paths and Windows paths.

There might still be a corner case here or there that doesn't work. The only cases I know are strings containing multiple device specifiers or colons.

Code:

Results:

path     = "/"
basename = "/"
dirname  = "/"

path     = "¥"
basename = "¥"
dirname  = "¥"

path     = ":"
basename = "."
dirname  = "."

path     = "mass0:"
basename = "."
dirname  = "mass0:"

path     = "mass0:/"
basename = "."
dirname  = "mass0:/"

path     = "mass0:something"
basename = "something"
dirname  = "mass0:"

path     = "mass0:/something"
basename = "something"
dirname  = "mass0:/"

path     = "mass0:something/"
basename = "something"
dirname  = "mass0:"

path     = "mass0:/something/"
basename = "something"
dirname  = "mass0:/"

path     = "mass0:something/is"
basename = "is"
dirname  = "mass0:something"

path     = "mass0:/something/is"
basename = "is"
dirname  = "mass0:/something"

path     = "mass0:/something/is/"
basename = "is"
dirname  = "mass0:/something"

path     = "mass0:/something/is/there"
basename = "there"
dirname  = "mass0:/something/is"

path     = "mass0:/something/is/there/"
basename = "there"
dirname  = "mass0:/something/is"

path     = "mass0:/something/is/there//"
basename = "there"
dirname  = "mass0:/something/is"

path     = "mass0:/something/is//there//"
basename = "there"
dirname  = "mass0:/something/is"

path     = "mass0:/something//is//there//"
basename = "there"
dirname  = "mass0:/something//is"



New Patch:
http://github.com/ragnarok2040/ps2sdk/commit/6b92a95c24a615ea437c1fb7855d61ff7830f2cb


Last edited by ragnarok2040 on Wed Aug 04, 2010 12:29 am; edited 3 times in total
Back to top
View user's profile Send private message
misfire



Joined: 06 Sep 2004
Posts: 120
Location: Germany

PostPosted: Thu Jul 22, 2010 8:47 pm    Post subject: Reply with quote

Cool patch. :)

Btw, I recommand posting small patches at pastie.org or a similar site.

For example:
http://pastie.org/1055093

To get the raw patch:
http://pastie.org/1055093.txt
Back to top
View user's profile Send private message
ragnarok2040



Joined: 09 Aug 2006
Posts: 230

PostPosted: Fri Jul 23, 2010 2:42 am    Post subject: Reply with quote

Thanks :D.

I knew of pastebin.com, but there was a symbol they used that caused diffs to be displayed wrong. I think it was @@. That may not be true any longer since the redesign, however.

Pastie.org looks nice, though, so I'll use that in the future, :D.

Edit:
I noticed a special case where paths like mass0:/something/ or mass0:\\something\\ would strip the slash or backslash after the device specifier so I updated the patch.
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Wed Aug 04, 2010 4:34 am    Post subject: Reply with quote

Apparently you can add ".diff" to that github URL to get a properly formatted patch. Nice. I applied this to ps2dev svn.
Back to top
View user's profile Send private message
ragnarok2040



Joined: 09 Aug 2006
Posts: 230

PostPosted: Wed Aug 04, 2010 6:22 pm    Post subject: Reply with quote

Nice, I didn't know that :D.

I've done quite a few commits over the past week or so but there's a couple I consider unstable. I'll make a new post and make a list of patches that should be included.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> Patch Submissions All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group