Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for FilePath #36

Open
zouppen opened this issue Mar 14, 2022 · 1 comment
Open

Add support for FilePath #36

zouppen opened this issue Mar 14, 2022 · 1 comment

Comments

@zouppen
Copy link

zouppen commented Mar 14, 2022

In my application I have difficulty to do reliable conversion of FilePath -> RawFilePath because of UTF-8 encoding of my path names in my operating system and if the file contains non-ASCII characters such as ä. Therefore it would be a good idea to add an alternative version of addWatch supporting regular FilePath. Without removing RawFilePath support, of course.

I know that RawFilePath is more performant, but in this case I don't need the performance but I'd like to see it not to break.

In case there is off-the-shelf solution for FilePath -> RawFilePath conversion which works on all file system encodings, please let me know and perhaps add it to README because some others might struggle with that. :-)

@thomasjm
Copy link
Contributor

FWIW, the fsnotify package does it like this:

toRawFilePath :: FilePath -> IO BS.ByteString
toRawFilePath fp = do
  enc <- getFileSystemEncoding
  F.withCString enc fp BS.packCString

fromRawFilePath :: BS.ByteString -> IO FilePath
fromRawFilePath bs = do
  enc <- getFileSystemEncoding
  BS.useAsCString bs (F.peekCString enc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants