View Single Post
Old 06-09-2010, 11:03 PM   #50
timlegge
Addict
timlegge loves his/her reader more than momtimlegge loves his/her reader more than momtimlegge loves his/her reader more than momtimlegge loves his/her reader more than momtimlegge loves his/her reader more than momtimlegge loves his/her reader more than momtimlegge loves his/her reader more than momtimlegge loves his/her reader more than momtimlegge loves his/her reader more than momtimlegge loves his/her reader more than momtimlegge loves his/her reader more than mom
 
Posts: 305
Karma: 78651
Join Date: May 2010
Location: New Brunswick, Canada
Device: Kobo, Kobo Wifi, Kobo Touch
Quote:
Originally Posted by chaley View Post
Tim,

The path separator issue has bitten me more than once.

The 'rules' are:
- lpath must always be the path from the mount point, and must always be forward slashed. It must not have a leading slash.
- path must be the complete path, and must always use os.sep.
- prefix must be the path to the root of the storage, and must use os.sep. It must have a trailing os.sep.

If you carefully follow these rules, then all the various bits of software will know what to do when constructing and manipulating paths.
Thanks for the rules I will look to see whether I comply. One of the complications in the case of the Kobo is that the path has to be derived the ContentID in the database. It refers to the device's internal location for the files with '/'s which means on Windows I have to deal with basckslashes in the path and forward slashes in the ContentID at the same time. I will probably create a ContentIDtoPath and PathtoContentID to simplify the code.

Quote:
Originally Posted by chaley View Post
You might not have noticed a new classfunction added to USBMS.driver, normalize_paths. It takes a constructed path (for example, os.path.join(prefix, lpath)) and returns that path corrected for the local OS and validated to be unicode. The base driver uses that function liberally.
I have been using them and they helped a lot.

Thanks

Tim
timlegge is offline   Reply With Quote