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

File/path utilities for crun runtime data. More...

#include <stdio.h>
#include <unistd.h>
Include dependency graph for crun_file_manager.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OS_HOME   getenv("HOME")
#define CRUN_DEFAULT_SUFFIX_DIRECTORY   "/.local/share/crun/"
#define CRUN_STACKS_JSON_FILE_URL   "https://raw.githubusercontent.com/ZouariOmar/cpkg/refs/heads/main/crun/crun_stacks.json"
#define CRUN_STACKS_JSON_FILE_DEFAULT_SUFFIX   CRUN_DEFAULT_SUFFIX_DIRECTORY "crun_stacks.json"
#define CRUN_TMP_DIRECTORY_SUFFIX   CRUN_DEFAULT_SUFFIX_DIRECTORY "tmp"

Functions

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

Detailed Description

File/path utilities for crun runtime data.

Author
ZouariOmar (zouar.nosp@m.ioma.nosp@m.r20@g.nosp@m.mail.nosp@m..com)
Version
0.3
Date
2026-03-18

crun_file_manager.h

Macro Definition Documentation

◆ CRUN_DEFAULT_SUFFIX_DIRECTORY

#define CRUN_DEFAULT_SUFFIX_DIRECTORY   "/.local/share/crun/"

◆ CRUN_STACKS_JSON_FILE_DEFAULT_SUFFIX

#define CRUN_STACKS_JSON_FILE_DEFAULT_SUFFIX   CRUN_DEFAULT_SUFFIX_DIRECTORY "crun_stacks.json"

◆ CRUN_STACKS_JSON_FILE_URL

#define CRUN_STACKS_JSON_FILE_URL   "https://raw.githubusercontent.com/ZouariOmar/cpkg/refs/heads/main/crun/crun_stacks.json"

◆ CRUN_TMP_DIRECTORY_SUFFIX

#define CRUN_TMP_DIRECTORY_SUFFIX   CRUN_DEFAULT_SUFFIX_DIRECTORY "tmp"

◆ OS_HOME

#define OS_HOME   getenv("HOME")

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: