Skip to content

stort0/cfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ Warning
The library is currently being tested.

CFS: cross-platform filesystem API in C89

A single header implementation of std::filesystem/Boost.Filesystem in C89.

⚠️ Warning
The library will not compile in a C++ environment (yet).
Define CFS_IMPLEMENTATION in a C file instead.

Usage:

// This should be done in a source file, not a header file.

// For Linux:
// #define _GNU_SOURCE (recommended, required for some functions, not required in C++).
//  This should be defined as a compiler definition, not using a #define.
//  If defined in a .c file, it should be above all #includes.

// For Windows:
//  Be sure to use a toolchain that automatically defines _WIN32_WINNT
//  to enable symlinks. _WIN32_WINNT is required to use symlinks

#define CFS_IMPLEMENTATION
#include <cfs/cfs.h>

OS requirements

Windows Linux
Windows 95+* Any

* Only compatibility with Windows 2000+ are tested in a VM. Older Windows versions are checked by modifying the _WIN32_WINNT value.

Some specific fixes are implemented for FreeBSD and Darwin but compatibility won't be tested.

Differences with std::filesystem

std::filesystem implementation across compilers is extremely inconsistent. This library adopts the most common or logical way across various implementations, or a custom one.

  • On Windows, paths above MAX_PATH (260 chars) length are supported.
  • Empty paths "" are not transformed in "." and NULL paths are treated as an error in Debug (fs_cfs_error_invalid_argument) or undefined behaviour in Release mode.
  • fs_file_time_type is based on the UNIX epoch on all OSs.
  • fs_hard_link_count always does not include the file itself as a link for consistency across operating systems.

Releases

No releases published

Languages