7 n__files_8h
gullradriel edited this page 2026-10-29 20:54:40 +01:00

include/nilorea/n_files.h

Files configuration header. More...

Structures

Name
struct N_FILE_INFO
common file information

Detailed Description

Files configuration header.

Author: Castagnier Mickael

Version: 1.0

Date: 02/11/23

Source code

/*
 * Nilorea Library
 * Copyright (C) 2005-2026 Castagnier Mickael
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */


#ifndef __N_FILES_HEADER
#define __N_FILES_HEADER

#ifdef __cplusplus
extern "C" {
#endif


#include <stdint.h>

#include "nilorea/n_str.h"
#include "nilorea/n_list.h"
#include "nilorea/n_log.h"
#include "dirent.h"

typedef struct N_FILE_INFO {
    char* name;
    time_t filetime, filetime_nsec;
} N_FILE_INFO;

int n_scan_dir(const char* dir, LIST* result, const int recurse);
void n_free_file_info(void* ptr);

int n_file_read_bounded(const char* path, size_t max_size, unsigned char** out, size_t* out_len);

int n_file_write_atomic(const char* path, const unsigned char* data, size_t len, int mode);

int n_file_copy_verified(const char* from, const char* to, size_t* copied);

int n_file_same_content(const char* a, const char* b);

int n_file_free_space(const char* path, uint64_t* bytes);


#ifdef __cplusplus
}
#endif

#endif