view th_file.h @ 740:caeb0a44ebdf

Change th_get_config_dir() API.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 14 Dec 2022 01:31:51 +0200
parents 31bc1ed07cf5
children 0852bd106034
line wrap: on
line source

/*
 * File, directory, path etc. related helper functions
 * Programmed and designed by Matti 'ccr' Hamalainen
 * (C) Copyright 2016-2022 Tecnic Software productions (TNSP)
 *
 * Please read file 'COPYING' for information on license and distribution.
 */
/// @file
/// @brief File, directory, path etc. related helper functions
#ifndef TH_FILE_H
#define TH_FILE_H

#include "th_types.h"

#ifdef __cplusplus
extern "C" {
#endif

// Platform specific defines
#if defined(TH_PLAT_WINDOWS) || defined(TH_PLAT_DOS)
#    define TH_DIR_SEPARATOR_CHR '\\'
#    define TH_DIR_SEPARATOR_STR "\\"
#else
#    define TH_DIR_SEPARATOR_CHR '/'
#    define TH_DIR_SEPARATOR_STR "/"
#endif


// Flags for th_stat_path()
enum
{
    TH_IS_DIR      = 0x1000,
    TH_IS_SYMLINK  = 0x2000,

    TH_IS_WRITABLE = 0x0002,
    TH_IS_READABLE = 0x0004,
};


typedef struct
{
    int flags;
    uint64_t size;
    uint64_t atime, mtime, ctime;
} th_stat_data;


char *  th_get_home_dir(void);
char *  th_get_config_dir(void);

bool    th_stat_path(const char *path, th_stat_data *data);
bool    th_mkdir_path(const char *path, const int mode);


#ifdef __cplusplus
}
#endif
#endif // TH_FILE_H