navit  0.5.3-trunk
file.c File Reference
#include "config.h"
#include "navit_lfs.h"
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <wordexp.h>
#include <glib.h>
#include <zlib.h>
#include "debug.h"
#include "cache.h"
#include "file.h"
#include "atom.h"
#include "item.h"
#include "util.h"
#include "types.h"
#include "zipfile.h"

Data Structures

struct  file_cache_id
 
struct  file_wordexp
 

Macros

#define S_ISDIR(m)   (((m) & S_IFMT) == S_IFDIR)
 
#define S_ISREG(m)   (((m) & S_IFMT) == S_IFREG)
 

Functions

static unsigned char * file_http_header_end (unsigned char *str, int len)
 
int file_request (struct file *f, struct attr **options)
 
char * file_http_header (struct file *f, char *header)
 
struct filefile_create (char *name, struct attr **options)
 
int file_is_dir (const char *name)
 Check if a given path corresponds to a directory. More...
 
int file_is_reg (const char *name)
 Check if a given path corresponds to a regular file. More...
 
long long file_size (struct file *file)
 
int file_mkdir (char *name, int pflag)
 
int file_mmap (struct file *file)
 
unsigned char * file_data_read (struct file *file, long long offset, int size)
 
static void file_process_headers (struct file *file, unsigned char *headers)
 
static void file_shift_buffer (struct file *file, int amount)
 
unsigned char * file_data_read_special (struct file *file, int size, int *size_ret)
 
unsigned char * file_data_read_all (struct file *file)
 
void file_data_flush (struct file *file, long long offset, int size)
 
int file_data_write (struct file *file, long long offset, int size, const void *data)
 
int file_get_contents (char *name, unsigned char **buffer, int *size)
 
static int uncompress_int (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
 
unsigned char * file_data_read_compressed (struct file *file, long long offset, int size, int size_uncomp)
 
void file_data_free (struct file *file, unsigned char *data)
 
void file_data_remove (struct file *file, unsigned char *data)
 
int file_exists (char const *name)
 
void file_remap_readonly (struct file *f)
 
void file_unmap (struct file *f)
 
void * file_opendir (char *dir)
 
char * file_readdir (void *hnd)
 
void file_closedir (void *hnd)
 
struct filefile_create_caseinsensitive (char *name, struct attr **options)
 
void file_fsync (struct file *f)
 
void file_destroy (struct file *f)
 
struct file_wordexpfile_wordexp_new (const char *pattern)
 
int file_wordexp_get_count (struct file_wordexp *wexp)
 
char ** file_wordexp_get_array (struct file_wordexp *wexp)
 
void file_wordexp_destroy (struct file_wordexp *wexp)
 
int file_version (struct file *file, int mode)
 
void * file_get_os_handle (struct file *file)
 
int file_set_cache_size (int cache_size)
 
void file_init (void)
 

Variables

static struct cachefile_cache
 
struct file_cache_id ATTRIBUTE_PACKED
 

Macro Definition Documentation

◆ S_ISDIR

#define S_ISDIR (   m)    (((m) & S_IFMT) == S_IFDIR)

◆ S_ISREG

#define S_ISREG (   m)    (((m) & S_IFMT) == S_IFREG)

Function Documentation

◆ file_closedir()

void file_closedir ( void *  hnd)

◆ file_create()

◆ file_create_caseinsensitive()

struct file* file_create_caseinsensitive ( char *  name,
struct attr **  options 
)

◆ file_data_flush()

void file_data_flush ( struct file file,
long long  offset,
int  size 
)

◆ file_data_free()

◆ file_data_read()

◆ file_data_read_all()

unsigned char* file_data_read_all ( struct file file)

◆ file_data_read_compressed()

unsigned char* file_data_read_compressed ( struct file file,
long long  offset,
int  size,
int  size_uncomp 
)

◆ file_data_read_special()

◆ file_data_remove()

void file_data_remove ( struct file file,
unsigned char *  data 
)

◆ file_data_write()

int file_data_write ( struct file file,
long long  offset,
int  size,
const void *  data 
)

◆ file_destroy()

◆ file_exists()

◆ file_fsync()

void file_fsync ( struct file f)

References file::f.

Referenced by vehicle_file_destroy().

◆ file_get_contents()

int file_get_contents ( char *  name,
unsigned char **  buffer,
int *  size 
)

◆ file_get_os_handle()

void* file_get_os_handle ( struct file file)

References file::fd.

◆ file_http_header()

char* file_http_header ( struct file f,
char *  header 
)

◆ file_http_header_end()

static unsigned char* file_http_header_end ( unsigned char *  str,
int  len 
)
static

References attr::str.

Referenced by file_data_read_special().

◆ file_init()

void file_init ( void  )

References cache_new(), dbg, file_cache, and lvl_error.

Referenced by add_plugin(), and main_real().

◆ file_is_dir()

int file_is_dir ( const char *  name)

Check if a given path corresponds to a directory.

Parameters
nameThe path to the filesystem element
Returns
!=0 (true) if name is a directory

References name, and S_ISDIR.

Referenced by file_mkdir(), and xinclude().

◆ file_is_reg()

int file_is_reg ( const char *  name)

Check if a given path corresponds to a regular file.

Parameters
nameThe path to the filesystem element
Returns
!=0 (true) if name is a regular file

References name, and S_ISREG.

Referenced by vehicle_file_open().

◆ file_mkdir()

int file_mkdir ( char *  name,
int  pflag 
)

◆ file_mmap()

◆ file_opendir()

void* file_opendir ( char *  dir)

◆ file_process_headers()

static void file_process_headers ( struct file file,
unsigned char *  headers 
)
static

◆ file_readdir()

char* file_readdir ( void *  hnd)

◆ file_remap_readonly()

void file_remap_readonly ( struct file f)

References file::begin, file::fd, and file::size.

◆ file_request()

int file_request ( struct file f,
struct attr **  options 
)

◆ file_set_cache_size()

int file_set_cache_size ( int  cache_size)

References cache_resize(), and file_cache.

Referenced by config_set_attr_int().

◆ file_shift_buffer()

static void file_shift_buffer ( struct file file,
int  amount 
)
static

References file::buffer, and file::buffer_len.

Referenced by file_data_read_special().

◆ file_size()

long long file_size ( struct file file)

◆ file_unmap()

void file_unmap ( struct file f)

References file::begin, and file::size.

Referenced by file_destroy().

◆ file_version()

int file_version ( struct file file,
int  mode 
)

◆ file_wordexp_destroy()

◆ file_wordexp_get_array()

◆ file_wordexp_get_count()

◆ file_wordexp_new()

◆ uncompress_int()

static int uncompress_int ( Bytef *  dest,
uLongf *  destLen,
const Bytef *  source,
uLong  sourceLen 
)
static

References startup::dest, and err().

Referenced by file_data_read_compressed().

Variable Documentation

◆ ATTRIBUTE_PACKED

struct file_cache_id ATTRIBUTE_PACKED

◆ file_cache

struct cache* file_cache
static

Navit, a modular navigation system. Copyright (C) 2005-2011 Navit Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Referenced by file_data_flush(), file_data_free(), file_data_read(), file_data_read_compressed(), file_data_remove(), file_init(), and file_set_cache_size().