File/path utilities for crun runtime data.
More...
#include <stdio.h>
#include <unistd.h>
Go to the source code of this file.
|
| 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.
|
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
- Copyright
- Copyright (c) 2025
crun_file_manager.h
◆ CRUN_DEFAULT_SUFFIX_DIRECTORY
| #define CRUN_DEFAULT_SUFFIX_DIRECTORY "/.local/share/crun/" |
◆ CRUN_STACKS_JSON_FILE_DEFAULT_SUFFIX
◆ 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
◆ OS_HOME
| #define OS_HOME getenv("HOME") |
◆ 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_path | Existing file path. |
| target_path | Destination file path. |
- Returns
- int EXIT_SUCCESS on success, EXIT_FAILURE otherwise.
◆ get_file_data()
| char * get_file_data |
( |
const char * | filename | ) |
|
Read full file content into a null-terminated buffer.
- Parameters
-
| filename | Absolute/relative file path. |
- Returns
- char* Allocated buffer (caller frees), or NULL on failure.
◆ get_file_home_path()
| const char * get_file_home_path |
( |
const char * | suffix | ) |
|
Build home-based absolute path using suffix.
- Parameters
-
| suffix | Path suffix appended to OS home location. |
- Returns
- const char* Allocated path buffer (caller frees), or NULL on failure.
◆ get_file_size()
| const long get_file_size |
( |
FILE * | fp | ) |
|
Compute total file size for opened stream.
- Parameters
-
- Returns
- long File size in bytes, -1 on failure.
◆ is_file_exist()
| int is_file_exist |
( |
const char * | filename | ) |
|
Check if file or directory exists.
- Parameters
-
- Returns
- int Non-zero if path exists, zero otherwise.
◆ is_zip_archive()
| int is_zip_archive |
( |
const char * | filename | ) |
|
Detect whether a file is a ZIP archive using its signature.
- Parameters
-
| filename | Path to the file to inspect. |
- Returns
- int Non-zero if ZIP signature is detected, zero otherwise.