GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
file.c File Reference

Vector library (diglib) - file management. More...

#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <grass/gis.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
Include dependency graph for file.c:

Go to the source code of this file.

Functions

long dig_ftell (GVFILE *file)
 Get GVFILE position. More...
 
int dig_fseek (GVFILE *file, long offset, int whence)
 Set GVFILE position. More...
 
void dig_rewind (GVFILE *file)
 Rewind GVFILE position. More...
 
int dig_fflush (GVFILE *file)
 Flush GVFILE. More...
 
size_t dig_fread (void *ptr, size_t size, size_t nmemb, GVFILE *file)
 Read GVFILE. More...
 
size_t dig_fwrite (void *ptr, size_t size, size_t nmemb, GVFILE *file)
 Write GVFILE. More...
 
void dig_file_init (GVFILE *file)
 Initialize GVFILE. More...
 
int dig_file_load (GVFILE *file)
 Load opened GVFILE to memory. More...
 
void dig_file_free (GVFILE *file)
 Free GVFILE. More...
 

Detailed Description

Vector library (diglib) - file management.

Lower level functions for reading/writing/manipulating vectors.

Note: seems that the time is almost the same for both cases:

  • reading from file
  • load whole file to memory and read from memory

(C) 2001-2009 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Dave Gerdes, Radim Blazek

Definition in file file.c.

Function Documentation

int dig_fflush ( GVFILE *  file)

Flush GVFILE.

Parameters
filepointer to GVFILE structure
Returns
0

Definition at line 102 of file file.c.

Referenced by dig_write_plus_file(), main(), V1__rewrite_line_nat(), V1_delete_line_nat(), and V1_restore_line_nat().

void dig_file_free ( GVFILE *  file)

Free GVFILE.

Parameters
filepointer to GVFILE structure

Definition at line 269 of file file.c.

References G_free().

Referenced by V1_close_nat().

void dig_file_init ( GVFILE *  file)

Initialize GVFILE.

Parameters
[out]filepointer to GVFILE structure

Definition at line 168 of file file.c.

References NULL.

Referenced by V1_open_new_nat(), V1_open_old_nat(), V2_close_ogr(), V2_open_old_ogr(), Vect_cidx_open(), Vect_cidx_save(), Vect_open_spatial_index(), Vect_open_topo(), Vect_save_spatial_index(), and Vect_save_topo().

int dig_file_load ( GVFILE *  file)

Load opened GVFILE to memory.

Warning: position in file is set to the beginning.

Parameters
filepointer to GVFILE structure
Returns
1 loaded
0 not loaded
-1 error

Definition at line 190 of file file.c.

References G__getenv(), G_debug(), G_free(), G_strcasecmp(), G_warning(), tools::mode, NULL, tools::size, and stat.

Referenced by V1_open_old_nat().

size_t dig_fread ( void *  ptr,
size_t  size,
size_t  nmemb,
GVFILE *  file 
)

Read GVFILE.

Parameters
[out]ptrdata buffer
sizebuffer size
nmembnumber of members
filepointer to GVFILE structure
Returns
number of read members

Definition at line 122 of file file.c.

References int.

Referenced by dig__fread_port_C(), dig__fread_port_D(), dig__fread_port_F(), dig__fread_port_I(), dig__fread_port_L(), and dig__fread_port_S().

int dig_fseek ( GVFILE *  file,
long  offset,
int  whence 
)

Set GVFILE position.

Start positions:

  • SEEK_SET (start)
  • SEEK_CUR (current position)
  • SEEK_END (end)
Parameters
filepointer to GVFILE structure
offsetoffset position
whencestart position
Returns
0 OK
-1 error

Definition at line 60 of file file.c.

Referenced by dig__read_head(), dig__write_head(), dig_load_plus(), dig_Rd_Plus_head(), dig_Rd_spindx_head(), dig_read_cidx(), dig_read_cidx_head(), dig_read_spidx(), main(), V1__rewrite_line_nat(), V1_delete_line_nat(), V1_restore_line_nat(), V1_rewind_nat(), V1_rewrite_line_nat(), V1_write_line_nat(), and Vect_coor_info().

long dig_ftell ( GVFILE *  file)
size_t dig_fwrite ( void *  ptr,
size_t  size,
size_t  nmemb,
GVFILE *  file 
)

Write GVFILE.

Parameters
ptrdata buffer
sizebuffer size
nmembnumber of members
[out]filepointer to GVFILE structure
Returns
number of items written

Definition at line 154 of file file.c.

References G_fatal_error().

Referenced by dig__fwrite_port_C(), dig__fwrite_port_D(), dig__fwrite_port_F(), dig__fwrite_port_I(), dig__fwrite_port_L(), and dig__fwrite_port_S().

void dig_rewind ( GVFILE *  file)