GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d37ee165c
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

◆ dig_fflush()

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_write_plus_file(), and V1_delete_line_nat().

◆ dig_file_free()

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().

◆ dig_file_init()

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_open_fidx(), Vect_open_topo(), Vect_save_fidx(), Vect_save_sidx(), and Vect_save_topo().

◆ dig_file_load()

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.

◆ dig_fread()

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, 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().

◆ dig_fseek()

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(), V1_delete_line_nat(), V1_rewind_nat(), and Vect_coor_info().

◆ dig_ftell()

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_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().

◆ dig_fwrite()

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().

◆ dig_rewind()

void dig_rewind ( struct gvfile file)