Subversion Repositories public

Rev

Rev 136 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 136 Rev 218
Line 1144... Line 1144...
1144
 
1144
 
1145
 
1145
 
1146
/* ========================================================================= */
1146
/* ========================================================================= */
1147
/* garmin_save                                                               */
1147
/* garmin_save                                                               */
1148
/* ========================================================================= */
1148
/* ========================================================================= */
1149
 
-
 
1150
uint32
1149
uint32
1151
garmin_save ( garmin_data * data, const char * filename, const char * dir )
1150
garmin_save ( garmin_data * data, const char * filename, const char * dir )
1152
{
1151
{
-
 
1152
	return garmin_save_all (data, filename, dir, 0);
-
 
1153
}
-
 
1154
 
-
 
1155
uint32
-
 
1156
garmin_save_all ( garmin_data * data, const char * filename, const char * dir, int flag )
-
 
1157
{
1153
  int         fd;
1158
  int         fd;
1154
  uint8 *     buf;
1159
  uint8 *     buf;
1155
  uint8 *     pos;
1160
  uint8 *     pos;
1156
  uint8 *     marker;
1161
  uint8 *     marker;
1157
  uint32      bytes  = 0;
1162
  uint32      bytes  = 0;
Line 1169... Line 1174...
1169
      owner = sb.st_uid;
1174
      owner = sb.st_uid;
1170
      group = sb.st_gid;
1175
      group = sb.st_gid;
1171
    }
1176
    }
1172
 
1177
 
1173
    snprintf(path,sizeof(path)-1,"%s/%s",dir,filename);
1178
    snprintf(path,sizeof(path)-1,"%s/%s",dir,filename);
1174
    if ( stat(path,&sb) != -1 ) {
1179
    if ( stat(path,&sb) != -1 && !flag) {
1175
      /* Do NOT overwrite if the file is already there. */
1180
      /* Do NOT overwrite if the file is already there. */
1176
      return 0;
1181
      return 0;
1177
    }
1182
    }
1178
 
1183
 
1179
    if ( (fd = creat(path,0664)) != -1 ) {
1184
    if ( (fd = creat(path,0664)) != -1 ) {