use of org.geotoolkit.data.shapefile.lock.StorageFile in project geotoolkit by Geomatys.
the class StorageFileTest method testReplaceOriginal.
@Test
public void testReplaceOriginal() throws Exception {
final ShpFiles files1 = shpFiles1;
final AccessManager locker = files1.createLocker();
final ShpFileType type = PRJ;
StorageFile storagePRJ1 = locker.getStorageFile(type);
String writtenToStorageFile = "Copy";
writeData(storagePRJ1, writtenToStorageFile);
locker.disposeReaderAndWriters();
locker.replaceStorageFiles();
assertCorrectData(files1, type, writtenToStorageFile);
}
use of org.geotoolkit.data.shapefile.lock.StorageFile in project geotoolkit by Geomatys.
the class IndexedFidWriter method generate.
/**
* Generates the FID index file for the shpFiles
*/
public static void generate(final ShpFiles shpFiles) throws IOException {
LOGGER.log(Level.FINE, "Generating fids for {0}", shpFiles.get(SHP));
final AccessManager locker = shpFiles.createLocker();
ShxReader indexFile = null;
StorageFile file = locker.getStorageFile(FIX);
try {
indexFile = locker.getSHXReader(false);
// writer closes channel for you.
final IndexedFidWriter writer = locker.getFIXWriter(file);
for (int i = 0, j = indexFile.getRecordCount(); i < j; i++) {
writer.next();
}
} finally {
try {
locker.disposeReaderAndWriters();
locker.replaceStorageFiles();
} finally {
if (indexFile != null) {
indexFile.close();
}
}
}
}
Aggregations