basename/dirname 获取文件名/路径
2014-08-28 17:24
489 查看
http://ruby-doc.org/core-2.1.2/File.html#method-c-dirname
(1)basename(file_name [, suffix] ) → base_name
Returns the last component of the filename given in file_name, which can be formed using both
Returns all components of the filename given in file_name except the last one. The filename can be formed using both
(1)basename(file_name [, suffix] ) → base_name
Returns the last component of the filename given in file_name, which can be formed using both
File::SEPARATORand
File::ALT_SEPARATORas the separator when
File::ALT_SEPARATORis not
nil. If suffix is given and present at the end of file_name, it is removed.
File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb" File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
(2)dirname(file_name) → dir_name
Returns all components of the filename given in file_name except the last one. The filename can be formed using both
File::SEPARATORand
File::ALT_SEPARATORas the separator when
File::ALT_SEPARATORis not
nil.
File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work"
相关文章推荐
- 通过os中的os.path.basename获取路径中的文件名
- SHELL命令——取路径和文件名:dirname basename
- php路径目录解析函数dirname basename pathinfo区别及实例
- php路径目录解析函数dirname basename pathinfo区别及实例
- php路径目录解析函数dirname basename pathinfo区别及实例
- 【php】php路径目录解析函数dirname basename pathinfo区别及实例
- JavaScript获取当前文件全路径、当前目录、当前文件名
- VC中使用GetModuleFileName获取应用程序路径(转)
- 用GetModuleFileName获取程序当前执行文件名
- 如何获取mdb本身路径或文件名?
- php获取url字符串截取路径的文件名和扩展名的函数
- 利用 GetModuleFileName获取exe文件路径,,以显示bmp, jpg, png图片
- 有关从完整路径中如何获取文件名
- 获取短文件名或路径
- .NET CF获取当前dll及其调用程序的文件名和完全路径
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- VC中使用GetModuleFileName获取应用程序路径(转)
- 获取进程中的文件名.路径.大小.创建时间.修改时间.属性等
- ASP'禁止网页缓存,验证码生成,删除文件 iFileName 文件名 iPath 文件路径
- (备忘)vb根据文件完整路径获取文件名