Giter Site home page Giter Site logo

cfgpath's Introduction

cfgpath.h: Cross platform methods for obtaining paths to configuration files

Copyright 2013 Adam Nielsen [email protected]


This is a simple header file that provides a handful of functions to obtain paths to configuration files, regardless of the operating system the application is running under.

It requires no dependencies beyond each platform's standard API.

This code is placed in the public domain. You are free to use it for any purpose. If you add new platform support, please contribute a patch!

Basic use:

#include "cfgpath.h"

char cfgdir[MAX_PATH];
get_user_config_file(cfgdir, sizeof(cfgdir), "myapp");
if (cfgdir[0] == 0) {
    printf("Unable to find home directory.\n");
    return 1;
}
printf("Saving configuration file to %s\n", cfgdir);

To integrate it into your own project, just copy cfgpath.h. All the other files are for testing to make sure it works correctly, so you don't need them unless you intend to make changes and send me a patch.

Supported platforms are currently:

  • Linux
  • Mac OS X
  • Windows

Patches adding support for more platforms would be greatly appreciated.

cfgpath's People

Contributors

cajomar avatar cxong avatar lukelane124 avatar malvineous avatar phani92 avatar redl3east 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  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  avatar  avatar

cfgpath's Issues

Bad C++ compatibility

It's me again! Can you put all four functions in a namespace when compiling in c++?
Quick patch:

#ifdef __cplusplus
namespace cfgpath {
#endif

// code

#ifdef __cplusplus
} // cfgpath
#endif

Licensing is unclear

I really love this project, however, I am unable to incorporate it's wondrous abilities into our programs due to the licensing not being defined on this platform.
This stackoverflow answer mentioned it's public domain, but I can't verify the authenticity of that claim.

https://stackoverflow.com/a/18418391

Please update your license definition to match how you wish this code to be treated.
Thanks!!!!!

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.