English 中文(简体)
查阅与文字相同的档案
原标题:Accessing files in the same directory as script

我需要查阅与我的书目所在地有关的档案。

唯一发现的解决办法I是使用<代码>File.dirname (__FILE__),但如果该笔文字是从Symlink操作的,/code> ,则该链接的位置是存在的。

我更希望找到一种不考虑 FILE__的解决办法,如果它有某种联系,则在什么地方发现。 但是,如果没有其他办法,就应当知道这是否已经很幸运?

最佳回答

File.expand_path 帮助?

(登克塔有一九箱子,在上面尝试)

问题回答

我倾向于以下变量:File.expand_path(>)。 /other_file_in_same_dir , __FILE__

第二个论点是,相对道路将扩大。 这违反了现行工作名录。

你们总是可以执行像灯类的弹道——l美元(pwd),开立并穿透。 对于窗户来说,你将只是执行相应的窗户指挥(我假定存在!)





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签