82#include <grass/vect/dig_defines.h>
83#include <grass/glocale.h>
85#define RAST_MISC "cell_misc"
139 while (fgets(buf,
sizeof(buf), fd)) {
140 if (sscanf(buf,
"%1s", comment) != 1 || *comment ==
'#')
164 fprintf(fd,
"%s\n", buf);
183 char temp1[128], temp2[128];
196 else if (ts->count == 2)
197 sprintf(buf,
"%s / %s", temp1, temp2);
222 for (slash = buf; *slash; slash++)
284static int write_timestamp(
const char *maptype,
const char *dir,
285 const char *
name,
const struct TimeStamp *ts)
292 G_warning(_(
"Unable to create timestamp file for %s map <%s@%s>"),
301 G_warning(_(
"Invalid timestamp specified for %s map <%s@%s>"), maptype,
320static int read_timestamp(
const char *maptype,
const char *dir,
321 const char *
name,
const char *mapset,
322 struct TimeStamp *ts)
331 G_warning(_(
"Unable to open timestamp file for %s map <%s@%s>"),
332 maptype,
name, mapset);
340 G_warning(_(
"Invalid timestamp file for %s map <%s@%s>"), maptype,
name,
373 struct TimeStamp *ts)
375 return read_timestamp(
"raster",
RAST_MISC,
name, mapset, ts);
424 char path[GPATH_MAX + GNAME_MAX];
428 G_snprintf(ele, GNAME_MAX,
"%s_%s", GV_TIMESTAMP_ELEMENT, layer);
430 G_snprintf(ele, GNAME_MAX,
"%s_1", GV_TIMESTAMP_ELEMENT);
437 if (access(
path, R_OK) != 0)
457 const char *mapset,
struct TimeStamp *ts)
469 G_snprintf(ele, GNAME_MAX,
"%s_%s", GV_TIMESTAMP_ELEMENT, layer);
471 G_snprintf(ele, GNAME_MAX,
"%s_1", GV_TIMESTAMP_ELEMENT);
475 G_debug(1,
"Read timestamp <%s/%s>", dir, ele);
480 G_warning(_(
"Unable to open timestamp file for vector map <%s@%s>"),
489 G_warning(_(
"Invalid timestamp file for vector map <%s@%s>"),
name, mapset);
506 const struct TimeStamp *ts)
514 G_snprintf(ele, GNAME_MAX,
"%s_%s", GV_TIMESTAMP_ELEMENT, layer);
516 G_snprintf(ele, GNAME_MAX,
"%s_1", GV_TIMESTAMP_ELEMENT);
520 G_debug(1,
"Write timestamp <%s/%s>", dir, ele);
525 G_warning(_(
"Unable to create timestamp file for vector map <%s@%s>"),
534 G_warning(_(
"Invalid timestamp specified for vector map <%s@%s>"),
name,
557 G_snprintf(ele, GNAME_MAX,
"%s_%s", GV_TIMESTAMP_ELEMENT, layer);
559 G_snprintf(ele, GNAME_MAX,
"%s_1", GV_TIMESTAMP_ELEMENT);
593 struct TimeStamp *ts)
595 return read_timestamp(
"raster3d",
GRID3,
name, mapset, ts);
611 return write_timestamp(
"raster3d",
GRID3,
name, ts);
void datetime_copy(DateTime *dst, const DateTime *src)
Copies the DateTime [into/from ???] src.
int G_debug(int level, const char *msg,...)
Print debugging message.
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
const char * G_find_file2_misc(const char *dir, const char *element, const char *name, const char *mapset)
Searches for a misc file from the mapset search list or in a specified mapset. (look but don't touch)
void G_warning(const char *msg,...)
Print a warning message to stderr.
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
const char * G_mapset(void)
Get current mapset name.
FILE * G_fopen_old_misc(const char *dir, const char *element, const char *name, const char *mapset)
open a database misc file for reading
FILE * G_fopen_new_misc(const char *dir, const char *element, const char *name)
open a new database misc file
int G_remove(const char *element, const char *name)
Remove a database file.
int G_remove_misc(const char *dir, const char *element, const char *name)
Remove a database misc file.
int datetime_scan(DateTime *dt, const char *buf)
Convert the ascii string into a DateTime. This determines the mode/from/to based on the string,...
int G_snprintf(char *str, size_t size, const char *fmt,...)
snprintf() clone.
void G_init_timestamp(struct TimeStamp *ts)
Initialize timestamp structure.
int G_read_raster_timestamp(const char *name, const char *mapset, struct TimeStamp *ts)
Read timestamp from raster map.
int G_has_raster_timestamp(const char *name, const char *mapset)
Check if timestamp for raster map exists.
int G_has_raster3d_timestamp(const char *name, const char *mapset)
Check if timestamp for 3D raster map exists.
int G_write_timestamp(FILE *fd, const struct TimeStamp *ts)
Output TimeStamp structure to a file as a formatted string.
int G_format_timestamp(const struct TimeStamp *ts, char *buf)
Create text string from TimeStamp structure.
int G_read_raster3d_timestamp(const char *name, const char *mapset, struct TimeStamp *ts)
Read timestamp from 3D raster map.
int G_remove_raster3d_timestamp(const char *name)
Remove timestamp from 3D raster map.
int G__read_timestamp(FILE *fd, struct TimeStamp *ts)
Read timestamp.
void G_set_timestamp(struct TimeStamp *ts, const DateTime *dt)
Set timestamp (single)
int G_write_raster_timestamp(const char *name, const struct TimeStamp *ts)
Write timestamp of raster map.
int G_scan_timestamp(struct TimeStamp *ts, const char *buf)
Fill a TimeStamp structure from a datetime string.
void G_set_timestamp_range(struct TimeStamp *ts, const DateTime *dt1, const DateTime *dt2)
Set timestamp (range)
int G_has_vector_timestamp(const char *name, const char *layer, const char *mapset)
Check if timestamp for vector map exists.
int G_read_vector_timestamp(const char *name, const char *layer, const char *mapset, struct TimeStamp *ts)
Read timestamp from vector map.
int G_write_raster3d_timestamp(const char *name, const struct TimeStamp *ts)
Write timestamp of 3D raster map.
int G_write_vector_timestamp(const char *name, const char *layer, const struct TimeStamp *ts)
Write timestamp of vector map.
int G_remove_vector_timestamp(const char *name, const char *layer)
Remove timestamp from vector map.
void G_get_timestamps(const struct TimeStamp *ts, DateTime *dt1, DateTime *dt2, int *count)
Copy TimeStamp into [two] Datetimes structs.
int G_remove_raster_timestamp(const char *name)
Remove timestamp from raster map.