Giter Site home page Giter Site logo

ocamlpro / directories Goto Github PK

View Code? Open in Web Editor NEW
34.0 5.0 3.0 76 KB

directories is an OCaml library that provides configuration, cache and data paths (and more!) following the suitable conventions on Linux, macOS and Windows. The following conventions are used: XDG Base Directory Specification and xdg-user-dirs on Linux, Known Folders on Windows, Standard Directories on macOS.

License: ISC License

OCaml 99.78% Standard ML 0.22%
directories ocaml config cache data linux macos windows xdg knownfolders

directories's Introduction

directories Actions Status

directories is an OCaml library that provides configuration, cache and data paths (and more!) following the suitable conventions on Linux, macOS and Windows. It is inspired by similar libraries for other languages such as directories-jvm.

The following conventions are used:

On Linux and macOS it has no dependency. On Windows, it depends only on ctypes.

Quickstart

You should depend on directories then :

let () =
  let module App_id = struct
    let qualifier = "com"
    let organization = "YourCompany"
    let application = "yourapp"
  end in
  let module M = Directories.Project_dirs (App_id) in
  let option_value = function None -> "None" | Some v -> v in
  Format.printf "cache dir  = `%s`@." (option_value M.cache_dir);
  Format.printf "config dir = `%s`@." (option_value M.config_dir);
  Format.printf "data dir   = `%s`@." (option_value M.data_dir)

For more, have a look at the example folder.

About

directories's People

Contributors

ddeclerck avatar delthas avatar zapashcanon avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

directories's Issues

Windows config_dir

Is there any reason that the Roaming %AppData% is chosen as the config_dir in the following

(** {FOLDERID_ApplicationData} *)
let config_dir = get_folderid GUID.ApplicationData

I've commonly seen XDG_CONFIG_HOME mapped to %LocalAppData%, like in https://docs.racket-lang.org/basedir/index.html . Either way makes sense (I'm not objecting), but since I'm evaluating making this package the standard for the DkML Windows distribution (once #14 is addressed) I'd love to understand.

xdg-user-dirs broken on linux

it's because $XDG_CONFIG_HOME/user-dirs.dirs isn't automatically exported, so we should do something like:

test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
echo ${XDG_DESKTOP_DIR:-$HOME/Desktop}
echo ...

and get all values.

Suggestion: remove ctypes dependency

On Windows, this package depends on Ctypes. A small C binding would be enough to replace its use (only two functions are needed).

In general, it is a pity that this small ligthweight library depends on another library (ctypes) which is several times its size (even if the dependency is only compile-time).

NTDDI_VERSION setting conflicts with _WIN32_WINNT setting

I'm compiling this on Windows using DkML (MSVC distribution):

#=== ERROR while compiling directories.0.5 ====================================#
# context     2.2.0~alpha0~20221228 | win32/x86_64 | conf-withdkml.2 ocaml-system.4.14.0 | pinned(https://github.com/OCamlPro/directories/archive/0.5.tar.gz)
# path        C:\Users\beckf\AppData\Local\opam\playground\.opam-switch\build\directories.0.5
# command     C:\Users\beckf\AppData\Local\Programs\DISKUV~1\bin\WITH-D~1.EXE dune build -p directories -j 11 @install
# exit-code   1
# env-file    C:\Users\beckf\AppData\Local\opam\log\directories-24340-62faa2.env
# output-file C:\Users\beckf\AppData\Local\opam\log\directories-24340-62faa2.out
### output ###
# File "_build/.dune/default/src/windows/bindings/dune", line 37, characters 36-57:
# 37 |  (foreign_stubs (language c) (names win_functions_c_stubs))
#                                          ^^^^^^^^^^^^^^^^^^^^^
# (cd _build/default/src/windows/bindings && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\cl.exe" -nologo -O2 -Gy- -MD -D_CRT_SECURE_NO_DEPRECATE -nologo -O2 -Gy- -MD -I C:/Users/beckf/AppData/Local/Programs/DISKUV~1/lib/ocaml -I C:\Users\beckf\AppData\Local\opam\playground\lib\bigarray-compat -I C:\Users\beckf\AppData\Local\opam\playg[...]
# win_functions_c_stubs.c
# C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared\sdkddkver.h(291): fatal error C1189: #error:  NTDDI_VERSION setting conflicts with _WIN32_WINNT setting



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build directories 0.5
└─
╶─ No changes have been performed

The important detail above is Windows SDK 10.0.18362.


I can't make sense of what the code is trying to do with cstubs. I believe

let () =
make_functions_stubs
[ "NTDDI_VERSION", "NTDDI_VISTA" ]
[ "windows.h"; "shlobj.h" ]
(module Win_functions_functor.Apply)
is doing the equivalent of:

#define NTDDI_VERSION NTDDI_VISTA

If that is true, then the code is missing the equivalent of:

#define _WIN32_WINNT _WIN32_WINNT_VISTA 

per (sometimes wrong) https://stackoverflow.com/questions/21030230/ntddi-version-setting-conflicts-with-win32-winnt-setting

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.