Ruby file full path -


I am writing a program where I cycle through the subfolders of a target folder through all the files and in it What is it written So my local folder looks like this

  folder - subfolder --- file --- file --- file - subfolder --- file. . .   

So I have one loop through all subfolders and for each subfolder, I'm calling a method that basically works the same, but in subfolder and every file Another method to call (parsing) is a file logic that I have a Dir.foreach (folder) {| File | Method (file)} was obtained through the command.

So it looks like: Dir.foreach (Dir.pwd) {| Folder | Call_method (folder)} def call_method (folder) Dir.foreach (folder) {| File | The method of reading (file)} end

that final method (read_method) should open the C method and paras as a full path to a file (so that the program can open it ) That's why I'm using reading the file. Instead of returning to C: / folder / subfolder / file in Read_method, it returns back as I want, except c: / folder / file subfolder (And thus failed to execute the program).

Is there a way to get the full path to that file?

Thank you for your help

EDIT: Here is the full code asked

  ## module module GBK_Reader PATH = "Z: / folder / "Security = true SAFETY_COUNT = 10 end ## Definition of methods def read_file (file) path = file. Bisolute_path (file) c_string = `C: /Code/GBK_Reader/bin/Debug/GBK_Reader.exe # {path}` return c_string.split (/) .collect {|! Imagine | Spec.to_i} End Def Read_folder (folder) Dir.foreach (folder) {| File | Next file if file.extname (file)! = ".gbk" temp = read_file (file) # $ Baktiria_spiisi [0] + = temp [0] # $ Baktiria_spiisi [1] + = Temporary [1]} for $ Baktiria_spiisi back end # # # main folder Dir .chdir (GBK_Reader :: PATH) puts "found in directory", through all sub-folders, $ high_gc = {} # high GC content puts # count = 0 to store bacteria "Array Variable Set" Dir. Foreach (Dir.pwd) {| File | Next if the file == "." || File == ".. if $ count = gtk = GBK_Reader :: SAFETY_COUNT $ count + = 1 if GBK_Reader :: security $ bacteria_spcs = [0.00, 0.00, 0.00] $ path = file.expant_path (file) if file directory? ( File) # All CyberChristmas and C program read_folder (file) and # call C program through all .gbk files in the subfolder to directly evaluate the GC content by c_string = red_file (file) if file. File (file) == ". Gbk "$ bacteria_specs [0] = c_string [0] .to_i $ bacteria_specs [1] = c_string [1] .to_i end # gc Store evaluate AOL Content and appropriate entries $ bacteria_specs in [2] = ($ Baktiria_spiisi [0] / $ Baktiria_spiisi [1]) * $ 100.00 Uchc_jisi [file] = $ Baktiria_spiisi that $ Baktiria_spiisis [2] & gt; 60} # Displays the appropriate entries "\ n \ n \ n" puts $ high_gc gets.chomp    

Well, I might have found something, but it looks ugly so that everyone can be better resolved in every way.

{| File | Next file if file.extname (file)! = ".gbk" path = File.absolute_path (folder) + '/' + file.basename (file) temp = read_file (path) $ bacteria_specs [0] + = temp [0] $ bacteria_spice [1] + = temporary [ 1]} Return to the end of $ bacteria_SPEC

And the path I expect is found. (Even though calling the program, I still fail, so I have to look elsewhere: D)

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -