GRASS GIS 7 Programmer's Manual  7.7.svn(2018)-r73600
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
file.c File Reference

Vector library - file management (lower level functions) More...

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

Go to the source code of this file.

Functions

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

Detailed Description

Vector library - file management (lower level functions)

Vector library - portability (lower level functions)

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
Original author CERL, probably Dave Gerdes
Update to GRASS 5.7 Radim Blazek

Lower level functions for reading/writing/manipulating vectors.

(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
Original author CERL, probably Dave Gerdes
Update to GRASS 5.7 Radim Blazek

Definition in file file.c.

Function Documentation

int dig_fflush ( struct gvfile file)

Flush struct gvfile.

Parameters
filepointer to struct gvfile structure
Returns
0

Definition at line 104 of file file.c.

References gvfile::file, and gvfile::loaded.

Referenced by dig_Wr_spidx(), dig_write_plus_file(), V1_delete_line_nat(), and V1_restore_line_nat().

void dig_file_free ( struct gvfile file)

Free struct gvfile.

Parameters
filepointer to struct gvfile structure

Definition at line 266 of file file.c.

References gvfile::alloc, G_free(), gvfile::loaded, and gvfile::start.

Referenced by V1_close_nat().

void dig_file_init ( struct gvfile file)

Initialize gvfile strcuture.

Parameters
[in,out]filepointer to gvfile structure

Definition at line 170 of file file.c.

References G_zero().

Referenced by V1_open_new_nat(), V1_open_old_nat(), Vect_cidx_open(), Vect_cidx_save(), Vect_open_fidx(), Vect_open_sidx(), Vect_open_topo(), Vect_save_fidx(), Vect_save_sidx(), and Vect_save_topo().

int dig_file_load ( struct gvfile file)

Load opened struct gvfile to memory.

Warning: position in file is set to the beginning.

Parameters
filepointer to struct gvfile structure
Returns
1 loaded
0 not loaded
-1 error

Definition at line 187 of file file.c.

References _, gvfile::alloc, gvfile::current, gvfile::end, gvfile::file, G_debug(), G_free(), G_fseek(), G_getenv_nofatal(), G_strcasecmp(), G_warning(), GV_MEMORY_ALWAYS, GV_MEMORY_AUTO, GV_MEMORY_NEVER, gvfile::loaded, NULL, gvfile::size, and gvfile::start.

Referenced by V1_open_old_nat().

size_t dig_fread ( void *  ptr,
size_t  size,
size_t  nmemb,
struct gvfile file 
)

Read struct gvfile.

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

Definition at line 124 of file file.c.

References gvfile::current, gvfile::end, gvfile::file, int, and gvfile::loaded.

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

int dig_fseek ( struct gvfile file,
off_t  offset,
int  whence 
)

Set struct gvfile position.

Start positions:

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

Definition at line 60 of file file.c.

References gvfile::current, gvfile::file, G_fseek(), gvfile::loaded, gvfile::size, and gvfile::start.

Referenced by dig__read_head(), dig__write_head(), dig_load_plus(), dig_Rd_Plus_head(), dig_Rd_spidx_head(), dig_read_cidx(), dig_read_cidx_head(), rtree_search(), V1_delete_line_nat(), V1_restore_line_nat(), V1_rewind_nat(), and Vect_coor_info().

off_t dig_ftell ( struct gvfile file)

Get struct gvfile position.

Parameters
filepointer to struct gvfile structure
Returns
current file position

Definition at line 36 of file file.c.

References gvfile::current, gvfile::file, G_ftell(), gvfile::loaded, and gvfile::start.

Referenced by dig__write_head(), dig_Wr_Plus_head(), dig_Wr_spidx(), dig_Wr_spidx_head(), dig_write_areas(), dig_write_cidx(), dig_write_cidx_head(), dig_write_isles(), dig_write_lines(), dig_write_nodes(), V1_read_next_line_nat(), and Vect_coor_info().

size_t dig_fwrite ( const void *  ptr,
size_t  size,
size_t  nmemb,
struct gvfile file 
)

Write struct gvfile.

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

Definition at line 156 of file file.c.

References _, gvfile::file, G_fatal_error(), and gvfile::loaded.

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

void dig_rewind ( struct gvfile file)