[GRASS-SVN] r29606 -
grass/branches/releasebranch_6_3/imagery/i.ortho.photo/photo.rectify
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jan 8 08:13:55 EST 2008
Author: neteler
Date: 2008-01-08 08:13:55 -0500 (Tue, 08 Jan 2008)
New Revision: 29606
Modified:
grass/branches/releasebranch_6_3/imagery/i.ortho.photo/photo.rectify/write.c
Log:
create temp file if it doesn't exist; open fix; i18N (merge from HEAD)
Modified: grass/branches/releasebranch_6_3/imagery/i.ortho.photo/photo.rectify/write.c
===================================================================
--- grass/branches/releasebranch_6_3/imagery/i.ortho.photo/photo.rectify/write.c 2008-01-08 13:09:37 UTC (rev 29605)
+++ grass/branches/releasebranch_6_3/imagery/i.ortho.photo/photo.rectify/write.c 2008-01-08 13:13:55 UTC (rev 29606)
@@ -4,21 +4,27 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include <grass/glocale.h>
#include "global.h"
+
int write_matrix (int row, int col)
{
int n;
- off_t offset;
select_target_env();
- if(!temp_fd)
+
+ /* create temp file if it doesn't eexist */
+ if (!temp_fd || (fcntl (temp_fd, F_GETFD) == -1))
{
temp_name = G_tempfile();
temp_fd = creat(temp_name,0660);
}
+
for (n=0; n < matrix_rows; n++)
{
+ off_t offset;
+
offset = ((off_t) row++ * target_window.cols + col) * G_raster_size(map_type);
lseek(temp_fd,offset,SEEK_SET);
@@ -26,14 +32,16 @@
!= G_raster_size(map_type)*matrix_cols)
{
unlink(temp_name);
- G_fatal_error("error while writing to temp file: %s", strerror(errno));
+ G_fatal_error (_("Unable to write temp file: %s"), strerror(errno));
}
}
+
select_current_env();
return 0;
}
+
int write_map(char *name)
{
int fd, row;
@@ -43,23 +51,25 @@
rast = G_allocate_raster_buf(map_type);
close(temp_fd);
- temp_fd = open(temp_name,0);
+ temp_fd = open (temp_name, F_DUPFD);
fd = G_open_raster_new(name,map_type);
if(fd <=0)
- G_fatal_error("Can't open map %s", name);
+ G_fatal_error (_("Unable to open map %s"), name);
for(row = 0; row < target_window.rows; row++)
{
if(read(temp_fd,rast,target_window.cols * G_raster_size(map_type))
!= target_window.cols * G_raster_size(map_type))
- G_fatal_error("error writing row %d", row);
+ G_fatal_error (_("Unable to write row %d"), row);
+
if(G_put_raster_row(fd,rast, map_type) < 0)
{
- G_fatal_error("error while writing to raster map. You might want to check available disk space and write permissions.");
+ G_fatal_error (_("Unable to write raster map. You might want to check available disk space and write permissions."));
unlink(temp_name);
}
}
+
close(temp_fd);
unlink(temp_name);
G_close_cell(fd);
More information about the grass-commit
mailing list