GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
raster/close.c File Reference

Raster Library - Close raster file. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
#include "R.h"
Include dependency graph for raster/close.c:

Go to the source code of this file.

Macros

#define FORMAT_FILE   "f_format"
 
#define QUANT_FILE   "f_quant"
 
#define NULL_FILE   "null"
 
#define NULLC_FILE   "nullcmpr"
 

Functions

void Rast_close (int fd)
 Close a raster map. More...
 
void Rast_unopen (int fd)
 Unopen a raster map. More...
 
void Rast__unopen_all (void)
 Unopen all raster maps. More...
 
void Rast__close_null (int fd)
 

Detailed Description

Raster Library - Close raster file.

(C) 1999-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
USACERL and many others

Definition in file raster/close.c.

Macro Definition Documentation

◆ FORMAT_FILE

#define FORMAT_FILE   "f_format"

Definition at line 33 of file raster/close.c.

◆ NULL_FILE

#define NULL_FILE   "null"

Definition at line 35 of file raster/close.c.

Referenced by Rast__close_null().

◆ NULLC_FILE

#define NULLC_FILE   "nullcmpr"

Definition at line 37 of file raster/close.c.

◆ QUANT_FILE

#define QUANT_FILE   "f_quant"

Definition at line 34 of file raster/close.c.

Function Documentation

◆ Rast__close_null()

◆ Rast__unopen_all()

void Rast__unopen_all ( void  )

Unopen all raster maps.

Unopen all raster maps opened for write. Memory allocated for raster processing is freed, and the temporary file created when the raster map was opened is removed (see Creating and Opening New Raster Files). This routine is useful when errors are detected and it is desired to remove temporary files.

Returns
void

Definition at line 156 of file raster/close.c.

References R__::fileinfo, R__::fileinfo_count, fileinfo::open_mode, OPEN_NEW_COMPRESSED, and OPEN_NEW_UNCOMPRESSED.

Referenced by Rast__error_handler().

◆ Rast_close()

void Rast_close ( int  fd)

Close a raster map.

The raster map opened on file descriptor fd is closed. Memory allocated for raster processing is freed. If open for writing, skeletal support files for the new raster map are created as well.

Note: If a module wants to explicitly write support files (e.g., a specific color table) for a raster map it creates, it must do so after the raster map is closed. Otherwise the close will overwrite the support files. See Raster Map Layer Support Routines for routines which write raster support files.

If the map is a new floating point, move the .tmp file into the fcell element, create an empty file in the cell directory; write the floating-point range file; write a default quantization file quantization file is set here to round fp numbers (this is a default for now). create an empty category file, with max cat = max value (for backwards compatibility). Move the .tmp NULL-value bitmap file to the cell_misc directory.

Parameters
fdfile descriptor
Returns
void

Definition at line 99 of file raster/close.c.

References _, R__::fileinfo, R__::fileinfo_count, G_fatal_error(), fileinfo::open_mode, and OPEN_OLD.

Referenced by close_band_files(), IL_create_bitmask(), Rast_map_to_img_str(), and Rast_suppress_masking().

◆ Rast_unopen()

void Rast_unopen ( int  fd)

Unopen a raster map.

The raster map opened on file descriptor fd is closed. Memory allocated for raster processing is freed. If open for writing, the raster map is not created and the temporary file created when the raster map was opened is removed (see Creating and Opening New Raster Files). This routine is useful when errors are detected and it is desired to not create the new raster map. While it is true that the raster map will not be created if the module exits without closing the file, the temporary file will not be removed at module exit. GRASS database management will eventually remove the temporary file, but the file can be quite large and will take up disk space until GRASS does remove it. Use this routine as a courtesy to the user.

Parameters
fdfile descriptor
Returns
void

Definition at line 132 of file raster/close.c.

References _, R__::fileinfo, R__::fileinfo_count, G_fatal_error(), fileinfo::open_mode, and OPEN_OLD.

Referenced by Rast__check_for_auto_masking(), and Rast_get_vrt_row().