[GRASS-SVN] r73518 - in grass-addons/grass7/raster: r.stream.basins r.stream.channel r.stream.distance r.stream.order r.stream.segment r.stream.snap r.stream.stats
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 10 06:24:13 PDT 2018
Author: mmetz
Date: 2018-10-10 06:24:13 -0700 (Wed, 10 Oct 2018)
New Revision: 73518
Modified:
grass-addons/grass7/raster/r.stream.basins/io.c
grass-addons/grass7/raster/r.stream.channel/io.c
grass-addons/grass7/raster/r.stream.distance/io.c
grass-addons/grass7/raster/r.stream.order/io.c
grass-addons/grass7/raster/r.stream.segment/io.c
grass-addons/grass7/raster/r.stream.snap/io.c
grass-addons/grass7/raster/r.stream.stats/io.c
Log:
r.stream.*: use Segment_[open_close]()
Modified: grass-addons/grass7/raster/r.stream.basins/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.basins/io.c 2018-10-10 13:00:48 UTC (rev 73517)
+++ grass-addons/grass7/raster/r.stream.basins/io.c 2018-10-10 13:24:13 UTC (rev 73518)
@@ -325,7 +325,6 @@
*/
char *filename;
- int fd;
int local_number_of_segs;
seg->fd = -1;
@@ -359,29 +358,15 @@
}
filename = G_tempfile();
- fd = creat(filename, 0666);
if (0 >
- Segment_format(fd, seg->nrows, seg->ncols, srows, scols,
- seg->data_size)) {
- close(fd);
- unlink(filename);
- G_fatal_error(_("Unable to format segment"));
+ Segment_open(&(seg->seg), filename, seg->nrows, seg->ncols, srows, scols,
+ seg->data_size, number_of_segs)) {
+ G_fatal_error(_("Unable to open segment structure"));
}
- close(fd);
- if (0 > (fd = open(filename, 2))) {
- unlink(filename);
- G_fatal_error(_("Unable to re-open file '%s'"), filename);
- }
+ seg->filename = G_store(filename);
- if (0 > (fd = Segment_init(&(seg->seg), fd, number_of_segs))) {
- unlink(filename);
- G_fatal_error(_("Unable to init segment file or out of memory"));
- }
-
- seg->filename = G_store(filename);
- seg->fd = fd;
return 0;
}
@@ -666,9 +651,7 @@
/*
* release segment close files, set pointers to null;
*/
- Segment_release(&(seg->seg));
- close(seg->fd);
- unlink(seg->filename);
+ Segment_close(&(seg->seg));
if (seg->map_name)
G_free(seg->map_name);
Modified: grass-addons/grass7/raster/r.stream.channel/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.channel/io.c 2018-10-10 13:00:48 UTC (rev 73517)
+++ grass-addons/grass7/raster/r.stream.channel/io.c 2018-10-10 13:24:13 UTC (rev 73518)
@@ -325,7 +325,6 @@
*/
char *filename;
- int fd;
int local_number_of_segs;
seg->fd = -1;
@@ -359,29 +358,15 @@
}
filename = G_tempfile();
- fd = creat(filename, 0666);
if (0 >
- Segment_format(fd, seg->nrows, seg->ncols, srows, scols,
- seg->data_size)) {
- close(fd);
- unlink(filename);
- G_fatal_error(_("Unable to format segment"));
+ Segment_open(&(seg->seg), filename, seg->nrows, seg->ncols, srows, scols,
+ seg->data_size, number_of_segs)) {
+ G_fatal_error(_("Unable to open segment structure"));
}
- close(fd);
- if (0 > (fd = open(filename, 2))) {
- unlink(filename);
- G_fatal_error(_("Unable to re-open file '%s'"), filename);
- }
+ seg->filename = G_store(filename);
- if (0 > (fd = Segment_init(&(seg->seg), fd, number_of_segs))) {
- unlink(filename);
- G_fatal_error(_("Unable to init segment file or out of memory"));
- }
-
- seg->filename = G_store(filename);
- seg->fd = fd;
return 0;
}
@@ -666,9 +651,7 @@
/*
* release segment close files, set pointers to null;
*/
- Segment_release(&(seg->seg));
- close(seg->fd);
- unlink(seg->filename);
+ Segment_close(&(seg->seg));
if (seg->map_name)
G_free(seg->map_name);
Modified: grass-addons/grass7/raster/r.stream.distance/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.distance/io.c 2018-10-10 13:00:48 UTC (rev 73517)
+++ grass-addons/grass7/raster/r.stream.distance/io.c 2018-10-10 13:24:13 UTC (rev 73518)
@@ -325,7 +325,6 @@
*/
char *filename;
- int fd;
int local_number_of_segs;
seg->fd = -1;
@@ -359,29 +358,15 @@
}
filename = G_tempfile();
- fd = creat(filename, 0666);
if (0 >
- Segment_format(fd, seg->nrows, seg->ncols, srows, scols,
- seg->data_size)) {
- close(fd);
- unlink(filename);
- G_fatal_error(_("Unable to format segment"));
+ Segment_open(&(seg->seg), filename, seg->nrows, seg->ncols, srows, scols,
+ seg->data_size, number_of_segs)) {
+ G_fatal_error(_("Unable to open segment structure"));
}
- close(fd);
- if (0 > (fd = open(filename, 2))) {
- unlink(filename);
- G_fatal_error(_("Unable to re-open file '%s'"), filename);
- }
+ seg->filename = G_store(filename);
- if (0 > (fd = Segment_init(&(seg->seg), fd, number_of_segs))) {
- unlink(filename);
- G_fatal_error(_("Unable to init segment file or out of memory"));
- }
-
- seg->filename = G_store(filename);
- seg->fd = fd;
return 0;
}
@@ -666,9 +651,7 @@
/*
* release segment close files, set pointers to null;
*/
- Segment_release(&(seg->seg));
- close(seg->fd);
- unlink(seg->filename);
+ Segment_close(&(seg->seg));
if (seg->map_name)
G_free(seg->map_name);
Modified: grass-addons/grass7/raster/r.stream.order/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.order/io.c 2018-10-10 13:00:48 UTC (rev 73517)
+++ grass-addons/grass7/raster/r.stream.order/io.c 2018-10-10 13:24:13 UTC (rev 73518)
@@ -325,7 +325,6 @@
*/
char *filename;
- int fd;
int local_number_of_segs;
seg->fd = -1;
@@ -359,29 +358,15 @@
}
filename = G_tempfile();
- fd = creat(filename, 0666);
if (0 >
- Segment_format(fd, seg->nrows, seg->ncols, srows, scols,
- seg->data_size)) {
- close(fd);
- unlink(filename);
- G_fatal_error(_("Unable to format segment"));
+ Segment_open(&(seg->seg), filename, seg->nrows, seg->ncols, srows, scols,
+ seg->data_size, number_of_segs)) {
+ G_fatal_error(_("Unable to open segment structure"));
}
- close(fd);
- if (0 > (fd = open(filename, 2))) {
- unlink(filename);
- G_fatal_error(_("Unable to re-open file '%s'"), filename);
- }
+ seg->filename = G_store(filename);
- if (0 > (fd = Segment_init(&(seg->seg), fd, number_of_segs))) {
- unlink(filename);
- G_fatal_error(_("Unable to init segment file or out of memory"));
- }
-
- seg->filename = G_store(filename);
- seg->fd = fd;
return 0;
}
@@ -666,9 +651,7 @@
/*
* release segment close files, set pointers to null;
*/
- Segment_release(&(seg->seg));
- close(seg->fd);
- unlink(seg->filename);
+ Segment_close(&(seg->seg));
if (seg->map_name)
G_free(seg->map_name);
Modified: grass-addons/grass7/raster/r.stream.segment/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/io.c 2018-10-10 13:00:48 UTC (rev 73517)
+++ grass-addons/grass7/raster/r.stream.segment/io.c 2018-10-10 13:24:13 UTC (rev 73518)
@@ -325,7 +325,6 @@
*/
char *filename;
- int fd;
int local_number_of_segs;
seg->fd = -1;
@@ -359,29 +358,15 @@
}
filename = G_tempfile();
- fd = creat(filename, 0666);
if (0 >
- Segment_format(fd, seg->nrows, seg->ncols, srows, scols,
- seg->data_size)) {
- close(fd);
- unlink(filename);
- G_fatal_error(_("Unable to format segment"));
+ Segment_open(&(seg->seg), filename, seg->nrows, seg->ncols, srows, scols,
+ seg->data_size, number_of_segs)) {
+ G_fatal_error(_("Unable to open segment structure"));
}
- close(fd);
- if (0 > (fd = open(filename, 2))) {
- unlink(filename);
- G_fatal_error(_("Unable to re-open file '%s'"), filename);
- }
+ seg->filename = G_store(filename);
- if (0 > (fd = Segment_init(&(seg->seg), fd, number_of_segs))) {
- unlink(filename);
- G_fatal_error(_("Unable to init segment file or out of memory"));
- }
-
- seg->filename = G_store(filename);
- seg->fd = fd;
return 0;
}
@@ -666,9 +651,7 @@
/*
* release segment close files, set pointers to null;
*/
- Segment_release(&(seg->seg));
- close(seg->fd);
- unlink(seg->filename);
+ Segment_close(&(seg->seg));
if (seg->map_name)
G_free(seg->map_name);
Modified: grass-addons/grass7/raster/r.stream.snap/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.snap/io.c 2018-10-10 13:00:48 UTC (rev 73517)
+++ grass-addons/grass7/raster/r.stream.snap/io.c 2018-10-10 13:24:13 UTC (rev 73518)
@@ -325,7 +325,6 @@
*/
char *filename;
- int fd;
int local_number_of_segs;
seg->fd = -1;
@@ -359,29 +358,15 @@
}
filename = G_tempfile();
- fd = creat(filename, 0666);
if (0 >
- Segment_format(fd, seg->nrows, seg->ncols, srows, scols,
- seg->data_size)) {
- close(fd);
- unlink(filename);
- G_fatal_error(_("Unable to format segment"));
+ Segment_open(&(seg->seg), filename, seg->nrows, seg->ncols, srows, scols,
+ seg->data_size, number_of_segs)) {
+ G_fatal_error(_("Unable to open segment structure"));
}
- close(fd);
- if (0 > (fd = open(filename, 2))) {
- unlink(filename);
- G_fatal_error(_("Unable to re-open file '%s'"), filename);
- }
+ seg->filename = G_store(filename);
- if (0 > (fd = Segment_init(&(seg->seg), fd, number_of_segs))) {
- unlink(filename);
- G_fatal_error(_("Unable to init segment file or out of memory"));
- }
-
- seg->filename = G_store(filename);
- seg->fd = fd;
return 0;
}
@@ -666,9 +651,7 @@
/*
* release segment close files, set pointers to null;
*/
- Segment_release(&(seg->seg));
- close(seg->fd);
- unlink(seg->filename);
+ Segment_close(&(seg->seg));
if (seg->map_name)
G_free(seg->map_name);
Modified: grass-addons/grass7/raster/r.stream.stats/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.stats/io.c 2018-10-10 13:00:48 UTC (rev 73517)
+++ grass-addons/grass7/raster/r.stream.stats/io.c 2018-10-10 13:24:13 UTC (rev 73518)
@@ -325,7 +325,6 @@
*/
char *filename;
- int fd;
int local_number_of_segs;
seg->fd = -1;
@@ -359,29 +358,15 @@
}
filename = G_tempfile();
- fd = creat(filename, 0666);
if (0 >
- Segment_format(fd, seg->nrows, seg->ncols, srows, scols,
- seg->data_size)) {
- close(fd);
- unlink(filename);
- G_fatal_error(_("Unable to format segment"));
+ Segment_open(&(seg->seg), filename, seg->nrows, seg->ncols, srows, scols,
+ seg->data_size, number_of_segs)) {
+ G_fatal_error(_("Unable to open segment structure"));
}
- close(fd);
- if (0 > (fd = open(filename, 2))) {
- unlink(filename);
- G_fatal_error(_("Unable to re-open file '%s'"), filename);
- }
+ seg->filename = G_store(filename);
- if (0 > (fd = Segment_init(&(seg->seg), fd, number_of_segs))) {
- unlink(filename);
- G_fatal_error(_("Unable to init segment file or out of memory"));
- }
-
- seg->filename = G_store(filename);
- seg->fd = fd;
return 0;
}
@@ -666,9 +651,7 @@
/*
* release segment close files, set pointers to null;
*/
- Segment_release(&(seg->seg));
- close(seg->fd);
- unlink(seg->filename);
+ Segment_close(&(seg->seg));
if (seg->map_name)
G_free(seg->map_name);
More information about the grass-commit
mailing list