I've a module inside an environment I use that, when I choose a file from a File Dialog, store the path inside a variable (let say var path
).
I need than to get the list of all files within path and store it into an array.
So what I've tried is:
list = Dir[path + "*"]
the fact is that path is somethings like this:
D:\Google Drive\Samples\Black Octopus Sound\Drums - Kicks\
and when I read it, the array is empty. It's due to the fact that the slash should be /
instead of \
. So I've do this:
path = path.gsub('\\','\/')
but the result is:
D:\/Google Drive\/Samples\/Black Octopus Sound\/Drums - Kicks\/
looks like path stored in the variable is:
D:\\Google Drive\\Samples\\Black Octopus Sound\\Drums - Kicks\\
is that normal? Because If I just print the path, it looks correct:
D:\Google Drive\Samples\Black Octopus Sound\Drums - Kicks\
is this the intended bahaviour of escaping path in Ruby? Am I wrong? How can I best manage this situation?
And why can't I write:
path = "D:\Google Drive\Samples\Black Octopus Sound\Drums - Kicks\"
but only:
path = "D:\Google Drive\Samples\Black Octopus Sound\Drums - Kicks\ " // notice the last empty space in the end
it says unterminated string meets end of file