I am trying to find the answer from google, but i am failed.
I am familiar with python, in which we can check the platform-specific directory separator by "os.path.sep".
Is there a way or some constant in XPCOM component that can indicate the path separator?
Or is there a way to normalize the path specific to platform?
For example, user input a file path under window: C:/path1/path2/test.txt
Using nsILocalFile::initWithPath will throw exception if I do not make the path platform valid. The valid path should be "C:\path1\path2\test.txt". So I wonder there is way to make a path valid and can init the nsILocalFile.
You can use nsIIOService.newURI with a file:// URI, and get a nsIFileURL object back, from which you can get an nsIFile object back. You can get the path information from the nsIFile object.