Fossil

Check-in [f73ed21d3b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Always close opendir() objects if and only if successfully opened. Ticket [d7169e51ebb3400f6]
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f73ed21d3b6e58b54066d5312bacd0c936dc4b77
User & Date: drh 2011-02-16 19:19:28.032
Original Comment: Always close opendir() objects if and only if successfully opened. Ticket [6f8614716702180a0]
Context
2011-02-16
23:47
Update to the latest pre-release SQLite version (as part of the SQLite testing process). Update the makefiles to use SQLITE_ENABLE_STAT2. ... (check-in: c616cef3f7 user: drh tags: trunk)
22:55
merge trunk ... (Closed-Leaf check-in: 0eaf7528b1 user: bharder tags: bch)
19:19
Always close opendir() objects if and only if successfully opened. Ticket [d7169e51ebb3400f6] ... (check-in: f73ed21d3b user: drh tags: trunk)
19:13
For the ssh: transport method, use the -T option to disable pseudottys. Increase the size of the buffer for holding the MOTD. ... (check-in: 7c8519003d user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/add.c.
186
187
188
189
190
191
192
193
194

195
196
197
198
199
200
201
      }else if( file_isdir(zPath)==1 ){
        add_directory_content(zPath, pIgnore);
      }else if( file_isfile(zPath) ){
        db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath);
      }
      blob_resize(&path, origSize);
    }
  }
  closedir(d);

  blob_reset(&path);
}

/*
** Add all content of a directory.
*/
void add_directory(const char *zDir, int vid, Blob *pOmit, Stmt *pIgnore){







<
|
>







186
187
188
189
190
191
192

193
194
195
196
197
198
199
200
201
      }else if( file_isdir(zPath)==1 ){
        add_directory_content(zPath, pIgnore);
      }else if( file_isfile(zPath) ){
        db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath);
      }
      blob_resize(&path, origSize);
    }

    closedir(d);
  }
  blob_reset(&path);
}

/*
** Add all content of a directory.
*/
void add_directory(const char *zDir, int vid, Blob *pOmit, Stmt *pIgnore){
319
320
321
322
323
324
325
326
327

328
329
330
331
332
333
334
          db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath);
          printf("DELETED  %s\n", zPath);
        }
        blob_reset(&pathname);
      }
      blob_resize(&path, origSize);
    }
  }
  closedir(d);

  blob_reset(&path);
}

/*
** COMMAND: rm
** COMMAND: delete
**







<
|
>







319
320
321
322
323
324
325

326
327
328
329
330
331
332
333
334
          db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath);
          printf("DELETED  %s\n", zPath);
        }
        blob_reset(&pathname);
      }
      blob_resize(&path, origSize);
    }

    closedir(d);
  }
  blob_reset(&path);
}

/*
** COMMAND: rm
** COMMAND: delete
**
Changes to src/rebuild.c.
600
601
602
603
604
605
606

607
608
609
610
611
612
613
      content_put(&aContent, 0, 0, 0);
      blob_reset(&path);
      blob_reset(&aContent);
      free(zSubpath);
      printf("\r%d", ++nFileRead);
      fflush(stdout);
    }

  }else {
    fossil_panic("encountered error %d while trying to open \"%s\".",
                  errno, g.argv[3]);
  }
}

/*







>







600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
      content_put(&aContent, 0, 0, 0);
      blob_reset(&path);
      blob_reset(&aContent);
      free(zSubpath);
      printf("\r%d", ++nFileRead);
      fflush(stdout);
    }
    closedir(d);
  }else {
    fossil_panic("encountered error %d while trying to open \"%s\".",
                  errno, g.argv[3]);
  }
}

/*
Changes to src/vfile.c.
308
309
310
311
312
313
314
315
316

317
318
319
320
321
322
323
      if( file_isdir(zPath)==1 ){
        vfile_scan(vid, pPath, nPrefix, allFlag);
      }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){
        db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]);
      }
      blob_resize(pPath, origSize);
    }
  }
  closedir(d);

}

/*
** Compute an aggregate MD5 checksum over the disk image of every
** file in vid.  The file names are part of the checksum.  The resulting
** checksum is the same as is expected on the R-card of a manifest.
**







<
|
>







308
309
310
311
312
313
314

315
316
317
318
319
320
321
322
323
      if( file_isdir(zPath)==1 ){
        vfile_scan(vid, pPath, nPrefix, allFlag);
      }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){
        db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]);
      }
      blob_resize(pPath, origSize);
    }

    closedir(d);
  }
}

/*
** Compute an aggregate MD5 checksum over the disk image of every
** file in vid.  The file names are part of the checksum.  The resulting
** checksum is the same as is expected on the R-card of a manifest.
**