💾 Archived View for gemlog.blue › users › verachell › 1645204000.gmi captured on 2024-03-21 at 17:18:34. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-03-01)
-=-=-=-=-=-=-
Note: This post is a Gemini space version of my post originally published on December 4, 2020
I had finished writing a piece of software in Ruby in for Linux and wanted to test it also on PC. Since the software involved reading in some data from files, I wanted to be sure that the pathnames could be handled on PC.
In Lisp, this is handled with relative ease where it's possible to specify the subdirectory of interest, and the file(s) within that, and it's up to the Lisp implementation to handle the differences between different operating systems.
I was rather expecting something similar for Ruby (given its influence from Lisp), but to my surprise, the official documentation on the File class had no information that I could find as to how pathnames would be handled differently on different operating systems.
Then I looked at the docs for the Ruby IO class
and I found the information there. It says:
Ruby will convert pathnames between different operating system conventions if possible. For instance, on a Windows system the filename "/gumby/ruby/test.rb" will be opened as "\gumby\ruby\test.rb". When specifying a Windows-style filename in a Ruby string, remember to escape the backslashes
This was wonderful news, and I was thrilled that I didn't have to alter any of my functions to make my software work on PC. But I was puzzled that this sort of info wasn't more prominently displayed on other pages where a file path is highly likely to be the argument of a function (e.g. in the docs for the File class).
Anyhow, I noted this down here just in case a) I need the information again and forget where to find it or b) in case anyone else was looking to do something cross-platform and searching for this sort of information.