Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,711
6,304
I have a text file containing a list of relative paths. The text file + the files those paths refer to are all on Github, and will be downloaded by both Windows and OS X users. How can I make it so that when Windows users get it, they'll see their correct path divider (\) and on OS X they'll get their correct path divider (/)?

It seems to me there aught to be some sort of script I can include in my GitHub repository that automatically runs itself and fixes all the paths each time a pull request is completed or something, but I can't for the life of me find it by googling.

Does anyone have any help?

(For what it's worth, this is regarding Android development. The project.properties file is a plain text file that contains paths that the compiler needs so that it can find the correct source files... it requires that the path separators be correct.)
 
I think I'd just make two files, one with each type of separator. Given them slightly different names, like Win-project.properties for the Windows-based one.

Given a file in /-separated form, it should be simple to write a script that converts to \-separated form, including any \-escaping that might (or might not) need to occur.

The 'tr' command can easily do single-character transliteration. So that would be my 1st choice for the / to \ conversion. If there were other things, like prepending C: or whatever, I might choose a different tool, or do the conversion in stages. Hard to say without seeing the actual data.

Oh, and I might file a feature-request against the Android dev tool to add a platform-neutral pathname capability. This is a solved problem. See the RFC for URLs and URIs, where the separator is always /, even if the server uses something else natively.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.