crun-cli v1.4.0
C-based project scaffolding CLI
Loading...
Searching...
No Matches
crun_file_manager.c File Reference

crun_file_manager source file More...

#include "../inc/crun_file_manager.h"
#include "../inc/crun_audit.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for crun_file_manager.c:

Macros

#define CRUN_IO_BUFFER_SIZE   8192

Functions

char * get_file_data (const char *filename)
 Read full file content into a null-terminated buffer.
int is_file_exist (const char *filename)
 Check if file or directory exists.
const char * get_file_home_path (const char *suffix)
 Build home-based absolute path using suffix.
const long get_file_size (FILE *fp)
 Compute total file size for opened stream.
int is_zip_archive (const char *filename)
 Detect whether a file is a ZIP archive using its signature.
int copy_file_to_path (const char *source_path, const char *target_path)
 Copy a file from source path to destination path.

Detailed Description

crun_file_manager source file

Author
ZouariOmar zouar.nosp@m.ioma.nosp@m.r20@g.nosp@m.mail.nosp@m..com
Version
0.1
Date
2025-12-26

crun_file_manager.c

Macro Definition Documentation

◆ CRUN_IO_BUFFER_SIZE

#define CRUN_IO_BUFFER_SIZE   8192

Function Documentation

◆ copy_file_to_path()

int copy_file_to_path ( const char * source_path,
const char * target_path )

Copy a file from source path to destination path.

Parameters
source_pathExisting file path.
target_pathDestination file path.
Returns
int EXIT_SUCCESS on success, EXIT_FAILURE otherwise.
Here is the call graph for this function:

◆ get_file_data()

char * get_file_data ( const char * filename)

Read full file content into a null-terminated buffer.

Parameters
filenameAbsolute/relative file path.
Returns
char* Allocated buffer (caller frees), or NULL on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_file_home_path()

const char * get_file_home_path ( const char * suffix)

Build home-based absolute path using suffix.

Parameters
suffixPath suffix appended to OS home location.
Returns
const char* Allocated path buffer (caller frees), or NULL on failure.
Here is the caller graph for this function:

◆ get_file_size()

const long get_file_size ( FILE * fp)

Compute total file size for opened stream.

Parameters
fpOpened file pointer.
Returns
long File size in bytes, -1 on failure.
Here is the caller graph for this function:

◆ is_file_exist()

int is_file_exist ( const char * filename)

Check if file or directory exists.

Parameters
filenamePath to check.
Returns
int Non-zero if path exists, zero otherwise.
Here is the caller graph for this function:

◆ is_zip_archive()

int is_zip_archive ( const char * filename)

Detect whether a file is a ZIP archive using its signature.

Parameters
filenamePath to the file to inspect.
Returns
int Non-zero if ZIP signature is detected, zero otherwise.
Here is the call graph for this function:
Here is the caller graph for this function: