Ejemplo n.º 1
0
  /**
   * Pack the file name information
   *
   * @param info File information to be packed.
   * @param buf Buffer to pack the data into.
   * @param uni Pack Unicode strings if true, else pack ASCII strings
   */
  protected static final void packInfoFileName(FileInfo info, DataBuffer buf, boolean uni) {

    //	Information format :-
    //		ULONG		NextEntryOffset
    //		ULONG		FileIndex
    //		ULONG 	FileNameLength
    //		STRING 	FileName

    //	Pack the file id

    int startPos = buf.getPosition();
    buf.putZeros(4);
    buf.putInt(EnableFileIdPacking ? info.getFileId() : 0);

    //	Pack the file name length

    int nameLen = info.getFileName().length();
    if (uni) nameLen *= 2;

    buf.putInt(nameLen);

    //	Pack the long file name string

    buf.putString(info.getFileName(), uni, false);

    //	Align the buffer pointer and set the offset to the next file information entry

    buf.longwordAlign();

    int curPos = buf.getPosition();
    buf.setPosition(startPos);
    buf.putInt(curPos - startPos);
    buf.setPosition(curPos);
  }
Ejemplo n.º 2
0
  /**
   * Pack the Macintosh format file/directory information
   *
   * @param info File information to be packed.
   * @param buf Buffer to pack the data into.
   * @param uni Pack Unicode strings if true, else pack ASCII strings
   */
  protected static final void packInfoMacHfs(FileInfo info, DataBuffer buf, boolean uni) {

    //	Information format :-
    //		ULONG	NextEntryOffset
    //		ULONG	FileIndex
    //		LARGE_INTEGER CreationTime
    //		LARGE_INTEGER LastWriteTime
    //		LARGE_INTEGER ChangeTime
    //		LARGE_INTEGER Data stream length
    //		LARGE_INTEGER Resource stream length
    //		LARGE_INTEGER Data stream allocation size
    //		LARGE_INTEGER Resource stream allocation size
    //		ULONG ExtFileAttributes
    //		UCHAR FLAttrib Macintosh SetFLock, 1 = file locked
    //		UCHAR Pad
    //		UWORD DrNmFls	Number of items in a directory, zero for files
    //		ULONG AccessControl
    //		UCHAR	FinderInfo[32]
    //		ULONG FileNameLength
    //		UCHAR ShortNameLength
    //		UCHAR Pad
    //		WCHAR ShortName[12]
    //		STRING FileName
    //		LONG UniqueId

    //	Pack the file id

    int startPos = buf.getPosition();
    buf.putZeros(4);
    buf.putInt(EnableFileIdPacking ? info.getFileId() : 0);

    //  Pack the creation date/time

    if (info.hasCreationDateTime()) {
      buf.putLong(NTTime.toNTTime(info.getCreationDateTime()));
    } else buf.putZeros(8);

    //  Pack the last write date/time and change time

    if (info.hasModifyDateTime()) {
      buf.putLong(NTTime.toNTTime(info.getModifyDateTime()));
      buf.putLong(NTTime.toNTTime(info.getModifyDateTime()));
    } else buf.putZeros(16);

    //  Pack the data stream size and resource stream size (always zero)

    buf.putLong(info.getSize());
    buf.putZeros(8);

    //	Pack the data stream allocation size and resource stream allocation size (always zero)

    if (info.getAllocationSize() < info.getSize()) buf.putLong(info.getSize());
    else buf.putLong(info.getAllocationSize());
    buf.putZeros(8);

    //  Pack the file attributes

    buf.putInt(info.getFileAttributes());

    //	Pack the file lock and padding byte

    buf.putZeros(2);

    //	Pack the number of items in a directory, always zero for now

    buf.putShort(0);

    //	Pack the access control

    buf.putInt(0);

    //	Pack the finder information

    buf.putZeros(32);

    //	Pack the file name length

    int nameLen = info.getFileName().length();
    if (uni) nameLen *= 2;

    buf.putInt(nameLen);

    //	Pack the short file name length (8.3 name) and name

    pack8Dot3Name(buf, info.getFileName(), uni);

    //	Pack the long file name string

    buf.putString(info.getFileName(), uni, false);

    //	Pack the unique id

    buf.putInt(0);

    //	Align the buffer pointer and set the offset to the next file information entry

    buf.longwordAlign();

    int curPos = buf.getPosition();
    buf.setPosition(startPos);
    buf.putInt(curPos - startPos);
    buf.setPosition(curPos);
  }
Ejemplo n.º 3
0
  /**
   * Pack the full file/directory information
   *
   * @param info File information to be packed.
   * @param buf Buffer to pack the data into.
   * @param uni Pack Unicode strings if true, else pack ASCII strings
   */
  protected static final void packInfoDirectoryBoth(FileInfo info, DataBuffer buf, boolean uni) {

    //	Information format :-
    //		ULONG	NextEntryOffset
    //		ULONG	FileIndex
    //		LARGE_INTEGER CreationTime
    //		LARGE_INTEGER LastAccessTime
    //		LARGE_INTEGER LastWriteTime
    //		LARGE_INTEGER ChangeTime
    //		LARGE_INTEGER EndOfFile
    //		LARGE_INTEGER AllocationSize
    //		ULONG FileAttributes
    //		ULONG FileNameLength
    //		ULONG EaSize
    //		UCHAR ShortNameLength
    //		WCHAR ShortName[12]
    //		STRING FileName

    //	Pack the file id

    int startPos = buf.getPosition();
    buf.putZeros(4);
    buf.putInt(EnableFileIdPacking ? info.getFileId() : 0);

    //  Pack the creation date/time

    if (info.hasCreationDateTime()) {
      buf.putLong(NTTime.toNTTime(info.getCreationDateTime()));
    } else buf.putZeros(8);

    //  Pack the last access date/time

    if (info.hasAccessDateTime()) {
      buf.putLong(NTTime.toNTTime(info.getAccessDateTime()));
    } else buf.putZeros(8);

    //  Pack the last write date/time and change time

    if (info.hasModifyDateTime()) {
      buf.putLong(NTTime.toNTTime(info.getModifyDateTime()));
      buf.putLong(NTTime.toNTTime(info.getModifyDateTime()));
    } else buf.putZeros(16);

    //  Pack the file size and allocation size

    buf.putLong(info.getSize());

    if (info.getAllocationSize() < info.getSize()) buf.putLong(info.getSize());
    else buf.putLong(info.getAllocationSize());

    //  Pack the file attributes

    buf.putInt(info.getFileAttributes());

    //	Pack the file name length

    int nameLen = info.getFileName().length();
    if (uni) nameLen *= 2;

    buf.putInt(nameLen);

    //	Pack the EA size, should always be 4.

    //		buf.putInt(4);
    buf.putInt(0);

    //	Pack the short file name length (8.3 name)

    pack8Dot3Name(buf, info.getFileName(), uni);

    //	Pack the long file name string

    buf.putString(info.getFileName(), uni, false);

    //	Align the buffer pointer and set the offset to the next file information entry

    buf.longwordAlign();

    int curPos = buf.getPosition();
    buf.setPosition(startPos);
    buf.putInt(curPos - startPos);
    buf.setPosition(curPos);
  }