Giter Club home page Giter Club logo

files.h's Introduction

files.h

Java-like virtual file objects in C.
Low-footprint and efficient: just one header file.
Made for simplicity.

Features

  • Manipulate file and directory paths.
  • Read/write to files.
  • Create new files/directories.
  • Check if files/directories and get their attributes.

Example

#include "files.h"

int main(int argc, char **argv)
{
    // --- File Tools:
    File *file = files_new("/etc/crontab");
    printf("Name: %s\n", files_get_name(file));
    printf("Path: %s\n", files_get_path(file));
    printf("URI: %s\n", files_get_uri(file));
    printf("Parent: %s\n", files_get_parent_path(file));
    printf("Contents: %s\n", files_contents_read(file));
    printf("Size: %ld\n", files_get_size(file));

    // --- Directory Tools:
    File *dir = files_new("./testdirectory/");

    if (!files_is_directory(dir))
    {
        files_mkdir(dir);
        // or
        files_mkdirp(dir, 0755);
    }

    // --- Write Tools:
    File *sample = files_new("./hello.txt");
    files_contents_write(sample, "Hello!");
    files_contents_append(sample, "Append me!");
    files_contents_prepend(sample, "Prepend me!");
}

More examples are in the tests folder.

Dependencies

If you're not running BSD, a recent version of libudev is required.

Versioning

This library is aimed to always be backwards-compatible. The function signatures will never be changed after the function has been added to the library.

The predefined LIBFILESHT_VERSION integer in files.h will be bumped every git commit which includes changes to files.h

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.