Пример #1
0
  private void addInfoFileConfigEntry(final OFile file) throws IOException {
    OStorageFileConfiguration[] newConfigFiles =
        new OStorageFileConfiguration[config.infoFiles.length + 1];
    for (int i = 0; i < config.infoFiles.length; ++i) newConfigFiles[i] = config.infoFiles[i];
    config.infoFiles = newConfigFiles;

    // CREATE A NEW ENTRY FOR THE NEW FILE
    String fileNameToStore =
        storage.getVariableParser().convertPathToRelative(OFileUtils.getPath(file.getPath()));

    final OStorageSegmentConfiguration template = config.root.fileTemplate;

    config.infoFiles[config.infoFiles.length - 1] =
        new OStorageFileConfiguration(
            config,
            fileNameToStore,
            template.fileType,
            template.fileMaxSize,
            template.fileIncrementSize);
  }
Пример #2
0
  public void truncate() throws IOException {
    // SHRINK TO 0
    files[0].shrink(0);

    if (files.length > 1) {
      // LEAVE JUST ONE FILE
      for (int i = 1; i < files.length; ++i) {
        if (files[i] != null) files[i].delete();
      }

      // UPDATE FILE STRUCTURE
      final OFile f = files[0];
      files = new OFile[1];
      files[0] = f;

      // UPDATE CONFIGURATION
      final OStorageFileConfiguration fileConfig = config.infoFiles[0];
      config.infoFiles = new OStorageFileConfiguration[1];
      config.infoFiles[0] = fileConfig;
      config.root.update();
    }
  }