Example #1
0
  private static void writeFileHeaders(Container container, File file) throws WriteHeaderException {
    WriteHeaderException error = null;
    try {
      RandomAccessFile rnd = new RandomAccessFile(container.getFileName(), "rw");
      try {
        rnd.seek(file.getOffset());
        rnd.write(
            generateHeader(
                file.getTypeId(),
                file.getId(),
                file.getOwnerId(),
                file.getCookie(),
                FileInContainer.FILE_EXISTS,
                file.getDataLength(),
                file.getTailId()));
      } catch (IOException e) {
        error = new WriteHeaderException("Writing header failed", e);
      }
      rnd.close();
    } catch (FileNotFoundException e) {
      error = new WriteHeaderException("Unable to open RandomAccessFile", e);
    } catch (IOException e) {
      error =
          new WriteHeaderException(
              "Unable to close either DataOutputStream (unlikely) or RandomAccessFile", e);
    }

    if (error != null) throw error;
  }
Example #2
0
 private void createFileHeader() throws IOException {
   fileHeader =
       TestableFileWriter.generateHeader(
           file.getTypeId(),
           file.getId(),
           file.getOwnerId(),
           file.getCookie(),
           FileInContainer.FILE_EXISTS,
           file.getDataLength(),
           file.getTailId());
 }