Below are revisions for this snippet.

Directory Utility





Syndication

Revision Revison 1
class Dir

def Dir.escape(path)
path_new = []
path.unpack("C*").map{ |n|
# meta char
if %q{"$&'()*/;<>?[\\`|}.include?(n)
path_new.push(0x5C) #=> 
path_new.push(n) #=>
# â€šÂ»â€šÃªË ÃˆÅ O
else
path_new.push(n)
end
}
path_new.pack("C*")
end

# getext
def Dir.getExt( fullpath )
len = fullpath.rindex('.')
return "." if len==nil
fullpath[ len , fullpath.length-len ]
end

# change ext
def Dir.subExt( filename , newext )
return if filename.rindex('.')==nil
newext = ('.'+newext) if newext[0]!='.'
filename.sub!( /\..+/,newext )
end

end
Revision Revison 2
Directory Utility for Ruby
Revision Revison 3
Directory Utility for Ruby