crun-cli v1.4.0
C-based project scaffolding CLI
Loading...
Searching...
No Matches
crun_file_manager.h
Go to the documentation of this file.
1
11
12#ifndef __CRUN_FILE_MANAGER_H__
13#define __CRUN_FILE_MANAGER_H__
14
15// #########################################
16// ### HEADERS & MACROS DECLARATION PART ###
17// #########################################
18
19#include <stdio.h>
20
21#ifdef _WIN32
22#include <io.h>
23#define OS_HOME getenv("APPDATA")
24#define F_OK 0
25#define access _access
26#define CRUN_DEFAULT_SUFFIX_DIRECTORY "\\crun\\"
27
28#else
29#include <unistd.h>
30#define OS_HOME getenv("HOME")
31#define CRUN_DEFAULT_SUFFIX_DIRECTORY "/.local/share/crun/"
32#endif
33
34#define CRUN_STACKS_JSON_FILE_URL "https://raw.githubusercontent.com/ZouariOmar/cpkg/refs/heads/main/crun/crun_stacks.json"
35#define CRUN_STACKS_JSON_FILE_DEFAULT_SUFFIX CRUN_DEFAULT_SUFFIX_DIRECTORY "crun_stacks.json"
36#define CRUN_TMP_DIRECTORY_SUFFIX CRUN_DEFAULT_SUFFIX_DIRECTORY "tmp"
37
38// ##################################
39// ### FUNCTIONS DECLARATION PART ###
40// ##################################
41
48char *get_file_data(const char *);
49
56int is_file_exist(const char *);
57
64const long get_file_size(FILE *);
65
72const char *get_file_home_path(const char *);
73
80int is_zip_archive(const char *);
81
89int copy_file_to_path(const char *, const char *);
90
91#endif // __CRUN_FILE_MANAGER_H__
char * get_file_data(const char *)
Read full file content into a null-terminated buffer.
Definition crun_file_manager.c:20
const long get_file_size(FILE *)
Compute total file size for opened stream.
Definition crun_file_manager.c:74
int copy_file_to_path(const char *, const char *)
Copy a file from source path to destination path.
Definition crun_file_manager.c:111
const char * get_file_home_path(const char *)
Build home-based absolute path using suffix.
Definition crun_file_manager.c:60
int is_file_exist(const char *)
Check if file or directory exists.
Definition crun_file_manager.c:56
int is_zip_archive(const char *)
Detect whether a file is a ZIP archive using its signature.
Definition crun_file_manager.c:84