Giter VIP home page Giter VIP logo

xdg-basedir's Introduction

XDG-BaseDir - The XDG Base Directory Specification

This library is, on the whole, trivial. But on the other hand, it is just complex enough for it to look really ugly when these functions have to be recoded time after time for different projects.

All functions in this library take a string representing the name of the program, and return one or more filepaths representing a directory.

  • getUserDataDir :: String -> IO FilePath
  • getUserDataFile :: String -> String -> IO FilePath
  • getUserConfigDir :: String -> IO FilePath
  • getUserConfigFile :: String -> String -> IO FilePath
  • getUserCacheDir :: String -> IO FilePath
  • getUserCacheFile :: String -> String -> IO FilePath
  • getSystemDataDirs :: String -> IO [FilePath]
  • getSystemDataFiles :: String -> String -> IO [FilePath]
  • getSystemConfigDirs :: String -> IO [FilePath]
  • getSystemConfigFiles :: String -> String -> IO [FilePath]
  • getAllDataDirs :: String -> IO [FilePath]
  • getAllDataFiles :: String -> String -> IO [FilePath]
  • getAllConfigDirs :: String -> IO [FilePath]
  • getAllConfigFiles :: String -> String -> IO [FilePath]

The 'Dir' and 'Dirs' variants of the functions return a directory or list of directories, whereas the 'File' and 'Files' functions are simply convenience functions which append a filename to the directories.

xdg-basedir's People

Contributors

kamaradclimber avatar rycee avatar willdonnelly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

xdg-basedir's Issues

Better type signatures

functions like getUserConfigFile should be rather like :: ApplicationName -> FilePath -> IO FilePath where type ApplicationName = FilePath to better hint at the usage.

Support $XDG_RUNTIME_DIR

$XDG_RUNTIME_DIR defines the base directory relative to which user-specific non-essential runtime files and other file objects (such as sockets, named pipes, ...) should be stored. The directory MUST be owned by the user, and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700.

The lifetime of the directory MUST be bound to the user being logged in. It MUST be created when the user first logs in and if the user fully logs out the directory MUST be removed. If the user logs in more than once he should get pointed to the same directory, and it is mandatory that the directory continues to exist from his first login to his last logout on the system, and not removed in between. Files in the directory MUST not survive reboot or a full logout/login cycle.

The directory MUST be on a local file system and not shared with any other system. The directory MUST by fully-featured by the standards of the operating system. More specifically, on Unix-like operating systems AF_UNIX sockets, symbolic links, hard links, proper permissions, file locking, sparse files, memory mapping, file change notifications, a reliable hard link count must be supported, and no restrictions on the file name character set should be imposed. Files in this directory MAY be subjected to periodic clean-up. To ensure that your files are not removed, they should have their access time timestamp modified at least once every 6 hours of monotonic time or the 'sticky' bit should be set on the file.

If $XDG_RUNTIME_DIR is not set applications should fall back to a replacement directory with similar capabilities and print a warning message. Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk.

Repository xdg-basedir.cabal seems out of date

On HackageDB is says that xdg-basedir is on version 0.2 while the xdg-basedir.cabal file in the repository says 0.1. Further, it seems to contain other information that is out of day, e.g., "category: Data" compared to "category: System" on HackageDB.

System.IO.Error Error

When attempting to install xdg-basedir with GHC 7.6.1, I get the following error:

Configuring xdg-basedir-0.2.1...
Building xdg-basedir-0.2.1...
Preprocessing library xdg-basedir-0.2.1...
[1 of 1] Compiling System.Environment.XDG.BaseDir ( System/Environment/XDG/BaseD
ir.hs, dist/build/System/Environment/XDG/BaseDir.o )

System/Environment/XDG/BaseDir.hs:23:29:
    Module `System.IO.Error' does not export `try'
Failed to install xdg-basedir-0.2.1

Handle missing $HOME gracefully

Under Linux, getHomeDirectory throws an exception if $HOME is not set. xdg-basedir should fail gracefully in these situations and ignore the home directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.