Java Code Examples for com.intellij.util.io.DataInputOutputUtil#writeTIME()

The following examples show how to use com.intellij.util.io.DataInputOutputUtil#writeTIME() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VfsDependentEnum.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void saveToFile(@Nonnull T instance) throws IOException {
  FileOutputStream fileOutputStream = new FileOutputStream(myFile, true);

  try (DataOutputStream output = new DataOutputStream(new BufferedOutputStream(fileOutputStream))) {
    if (myFile.length() == 0) {
      DataInputOutputUtil.writeTIME(output, FSRecords.getCreationTimestamp());
      DataInputOutputUtil.writeINT(output, myVersion);
    }
    myKeyDescriptor.save(output, instance);
  }
  finally {
    try {
      fileOutputStream.getFD().sync();
    }
    catch (IOException ignored) {
    }
  }
}
 
Example 2
Source File: StubUpdatingIndex.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void rememberIndexingStamp(@Nonnull VirtualFile file, boolean isBinary, long contentByteLength, int contentCharLength) {
  try (DataOutputStream stream = INDEXED_STAMP.writeAttribute(file)) {
    DataInputOutputUtil.writeTIME(stream, file.getTimeStamp());
    DataInputOutputUtil.writeLONG(stream, contentByteLength);

    boolean lengthsAreTheSame = contentByteLength == contentCharLength;
    byte flags = 0;
    flags = BitUtil.set(flags, IS_BINARY_MASK, isBinary);
    flags = BitUtil.set(flags, BYTE_AND_CHAR_LENGTHS_ARE_THE_SAME_MASK, lengthsAreTheSame);
    stream.writeByte(flags);

    if (!lengthsAreTheSame && !isBinary) {
      DataInputOutputUtil.writeINT(stream, contentCharLength);
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
 
Example 3
Source File: IndexingStamp.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void savePersistentIndexStamp(DataOutput out) throws IOException {
  DataInputOutputUtil.writeTIME(out, IndexVersion.ourLastStamp);
}
 
Example 4
Source File: IndexingStamp.java    From consulo with Apache License 2.0 4 votes vote down vote up
void write(DataOutput os) throws IOException {
  DataInputOutputUtil.writeINT(os, myIndexVersion);
  DataInputOutputUtil.writeINT(os, myCommonIndicesVersion);
  DataInputOutputUtil.writeTIME(os, myVfsCreationStamp);
  DataInputOutputUtil.writeTIME(os, myModificationCount);
}