libgpac
Documentation of the core library of GPAC
os_file.c File Reference
#include <gpac/tools.h>
#include <gpac/utf.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/time.h>
#include <errno.h>
#include <gpac/list.h>
#include <gpac/thread.h>
+ Include dependency graph for os_file.c:

Data Structures

struct  GF_FileHandle
 
struct  GF_FileIO
 
struct  GF_FileIOBlob
 

Functions

GF_EXPORT GF_Err gf_rmdir (const char *DirPathName)
 Delete Directory. More...
 
GF_EXPORT GF_Err gf_mkdir (const char *DirPathName)
 Create Directory. More...
 
GF_EXPORT Bool gf_dir_exists (const char *DirPathName)
 Check Directory Exists. More...
 
static Bool delete_dir (void *cbck, char *item_name, char *item_path, GF_FileEnumInfo *file_info)
 
GF_EXPORT GF_Err gf_dir_cleanup (const char *DirPathName)
 Create Directory. More...
 
GF_EXPORT GF_Err gf_file_delete (const char *fileName)
 File Deletion. More...
 
static char * gf_sanetize_single_quoted_string (const char *src)
 
GF_EXPORT Bool gf_file_exists_ex (const char *fileName, const char *par_name)
 File existence check. More...
 
GF_EXPORT Bool gf_file_exists (const char *fileName)
 File existence check. More...
 
GF_EXPORT GF_Err gf_file_move (const char *fileName, const char *newFileName)
 File Move. More...
 
GF_EXPORT u64 gf_file_modification_time (const char *filename)
 File Modification Time. More...
 
GF_EXPORT u32 gf_file_handles_count ()
 
static void gf_register_file_handle (char *filename, FILE *ptr, Bool is_temp_file)
 
static Bool gf_unregister_file_handle (FILE *ptr)
 
static FILE * gf_file_temp_os (char **const fileName)
 
GF_EXPORT FILE * gf_file_temp (char **const fileName)
 Temporary File Creation. More...
 
GF_EXPORT GF_Err gf_enum_directory (const char *dir, Bool enum_directory, gf_enum_dir_item enum_dir_fct, void *cbck, const char *filter)
 Directory enumeration. More...
 
GF_EXPORT Bool gf_fileio_check (FILE *fp)
 file IO checker More...
 
GF_EXPORT GF_FileIOWriteState gf_fileio_write_ready (FILE *fp)
 file IO write checker More...
 
u32 gf_fileio_get_write_rate (FILE *fp)
 
static GF_FileIO * gfio_blob_open (GF_FileIO *fileio_ref, const char *url, const char *mode, GF_Err *out_error)
 
static GF_Err gfio_blob_seek (GF_FileIO *fileio, u64 offset, s32 whence)
 
static u32 gfio_blob_read (GF_FileIO *fileio, u8 *buffer, u32 bytes)
 
static s64 gfio_blob_tell (GF_FileIO *fileio)
 
static Bool gfio_blob_eof (GF_FileIO *fileio)
 
static char * gfio_blob_gets (GF_FileIO *fileio, char *ptr, u32 size)
 
GF_EXPORT GF_FileIO * gf_fileio_new (char *url, void *udta, gfio_open_proc open, gfio_seek_proc seek, gfio_read_proc read, gfio_write_proc write, gfio_tell_proc tell, gfio_eof_proc eof, gfio_printf_proc printf)
 
GF_EXPORT const char * gf_fileio_url (GF_FileIO *gfio)
 
GF_EXPORT const char * gf_fileio_resource_url (GF_FileIO *gfio)
 
GF_EXPORT void gf_fileio_del (GF_FileIO *gfio)
 
GF_EXPORT void * gf_fileio_get_udta (GF_FileIO *gfio)
 
GF_EXPORT GF_FileIO * gf_fileio_open_url (GF_FileIO *gfio_ref, const char *url, const char *mode, GF_Err *out_err)
 
static u32 gf_fileio_read (GF_FileIO *gfio, u8 *buffer, u32 nb_bytes)
 
static u32 gf_fileio_write (GF_FileIO *gfio, u8 *buffer, u32 nb_bytes)
 
int gf_fileio_printf (GF_FileIO *gfio, const char *format, va_list args)
 
GF_EXPORT Bool gf_fileio_write_mode (GF_FileIO *gfio)
 
GF_EXPORT Bool gf_fileio_read_mode (GF_FileIO *gfio)
 
GF_EXPORT GF_FileIO * gf_fileio_from_url (const char *url)
 
GF_EXPORT const char * gf_fileio_translate_url (const char *url)
 
Bool gf_fileio_eof (GF_FileIO *fileio)
 
int gf_fileio_flush (GF_FileIO *fileio)
 
GF_EXPORT const char * gf_fileio_factory (GF_FileIO *gfio, const char *new_res_url)
 
GF_EXPORT void gf_fileio_set_stats (GF_FileIO *gfio, u64 bytes_done, u64 file_size, GF_FileIOCacheState cache_state, u32 bytes_per_sec)
 
GF_EXPORT void gf_fileio_set_write_state (GF_FileIO *gfio, GF_FileIOWriteState write_state)
 
GF_EXPORT Bool gf_fileio_get_stats (GF_FileIO *gfio, u64 *bytes_done, u64 *file_size, GF_FileIOCacheState *cache_state, u32 *bytes_per_sec)
 
GF_EXPORT GF_Err gf_fileio_tag_main_thread (GF_FileIO *fileio)
 
GF_EXPORT Bool gf_fileio_is_main_thread (const char *url)
 
GF_EXPORT u64 gf_ftell (FILE *fp)
 large file position query More...
 
GF_EXPORT s32 gf_fseek (FILE *fp, s64 offset, s32 whence)
 large file seeking More...
 
static GF_FileIO * gf_fileio_from_blob (const char *file_name)
 
GF_FileIO * gf_fileio_from_mem (const char *URL, const u8 *data, u32 size)
 
GF_EXPORT FILE * gf_fopen_ex (const char *file_name, const char *parent_name, const char *mode, Bool no_warn)
 file opening More...
 
GF_EXPORT s32 gf_fd_open (const char *file_name, u32 oflags, u32 uflags)
 Open file descriptor. More...
 
GF_EXPORT FILE * gf_fopen (const char *file_name, const char *mode)
 file opening More...
 
GF_EXPORT s32 gf_fclose (FILE *file)
 file closing More...
 
GF_EXPORT size_t gf_fwrite (const void *ptr, size_t nb_bytes, FILE *stream)
 file writing helper More...
 
GF_EXPORT size_t gf_fread (void *ptr, size_t nbytes, FILE *stream)
 file reading helper More...
 
GF_EXPORT char * gf_fgets (char *ptr, size_t size, FILE *stream)
 file reading helper More...
 
GF_EXPORT int gf_fgetc (FILE *stream)
 file reading helper More...
 
GF_EXPORT int gf_fputc (int val, FILE *stream)
 file writing helper More...
 
GF_EXPORT int gf_fputs (const char *buf, FILE *stream)
 file writing helper More...
 
GF_EXPORT int gf_fprintf (FILE *stream, const char *format,...)
 file writing helper More...
 
GF_EXPORT int gf_vfprintf (FILE *stream, const char *format, va_list args)
 file writing helper More...
 
GF_EXPORT int gf_fflush (FILE *stream)
 file flush helper More...
 
GF_EXPORT int gf_feof (FILE *stream)
 end of file helper More...
 
GF_EXPORT int gf_ferror (FILE *stream)
 file error helper More...
 
GF_EXPORT u64 gf_fsize (FILE *fp)
 file size helper More...
 
GF_EXPORT char * gf_file_basename (const char *filename)
 
GF_EXPORT char * gf_file_ext_start (const char *filename)
 
GF_EXPORT char * gf_url_colon_suffix (const char *path, char assign_sep)
 get first after a filename/path More...
 

Variables

int gf_mem_track_enabled
 
static GF_List * gpac_open_files = NULL
 
static u32 gpac_file_handles = 0
 
GF_Mutex * logs_mx
 

Data Structure Documentation

◆ GF_FileHandle

struct GF_FileHandle
Data Fields
FILE * ptr
char * url
Bool is_temp

◆ GF_FileIOBlob

struct GF_FileIOBlob
Data Fields
u8 * data
u32 size
u32 pos
u32 url_crc
u32 nb_ref

Function Documentation

◆ delete_dir()

static Bool delete_dir ( void *  cbck,
char *  item_name,
char *  item_path,
GF_FileEnumInfo file_info 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sanetize_single_quoted_string()

static char* gf_sanetize_single_quoted_string ( const char *  src)
static

Remove existing single-quote from a single-quoted string. The caller is responsible for deallocating the returns string with gf_free()

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_register_file_handle()

static void gf_register_file_handle ( char *  filename,
FILE *  ptr,
Bool  is_temp_file 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_unregister_file_handle()

static Bool gf_unregister_file_handle ( FILE *  ptr)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_file_temp_os()

static FILE* gf_file_temp_os ( char **const  fileName)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_fileio_get_write_rate()

u32 gf_fileio_get_write_rate ( FILE *  fp)

◆ gfio_blob_open()

static GF_FileIO* gfio_blob_open ( GF_FileIO *  fileio_ref,
const char *  url,
const char *  mode,
GF_Err out_error 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gfio_blob_seek()

static GF_Err gfio_blob_seek ( GF_FileIO *  fileio,
u64  offset,
s32  whence 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gfio_blob_read()

static u32 gfio_blob_read ( GF_FileIO *  fileio,
u8 buffer,
u32  bytes 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gfio_blob_tell()

static s64 gfio_blob_tell ( GF_FileIO *  fileio)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gfio_blob_eof()

static Bool gfio_blob_eof ( GF_FileIO *  fileio)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gfio_blob_gets()

static char* gfio_blob_gets ( GF_FileIO *  fileio,
char *  ptr,
u32  size 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_fileio_read()

static u32 gf_fileio_read ( GF_FileIO *  gfio,
u8 buffer,
u32  nb_bytes 
)
static
+ Here is the caller graph for this function:

◆ gf_fileio_write()

static u32 gf_fileio_write ( GF_FileIO *  gfio,
u8 buffer,
u32  nb_bytes 
)
static
+ Here is the caller graph for this function:

◆ gf_fileio_printf()

int gf_fileio_printf ( GF_FileIO *  gfio,
const char *  format,
va_list  args 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_fileio_eof()

Bool gf_fileio_eof ( GF_FileIO *  fileio)
+ Here is the caller graph for this function:

◆ gf_fileio_flush()

int gf_fileio_flush ( GF_FileIO *  fileio)
+ Here is the caller graph for this function:

◆ gf_fileio_from_blob()

static GF_FileIO* gf_fileio_from_blob ( const char *  file_name)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ gf_mem_track_enabled

int gf_mem_track_enabled
extern

◆ gpac_open_files

GF_List* gpac_open_files = NULL
static

◆ gpac_file_handles

u32 gpac_file_handles = 0
static

◆ logs_mx

GF_Mutex* logs_mx
extern