Esempio n. 1
0
 static SftpATTRS getATTR(Buffer buf) {
   SftpATTRS attr = new SftpATTRS();
   attr.flags = buf.getInt();
   if ((attr.flags & SSH_FILEXFER_ATTR_SIZE) != 0) {
     attr.size = buf.getLong();
   }
   if ((attr.flags & SSH_FILEXFER_ATTR_UIDGID) != 0) {
     attr.uid = buf.getInt();
     attr.gid = buf.getInt();
   }
   if ((attr.flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0) {
     attr.permissions = buf.getInt();
   }
   if ((attr.flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0) {
     attr.atime = buf.getInt();
   }
   if ((attr.flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0) {
     attr.mtime = buf.getInt();
   }
   if ((attr.flags & SSH_FILEXFER_ATTR_EXTENDED) != 0) {
     int count = buf.getInt();
     if (count > 0) {
       attr.extended = new String[count * 2];
       for (int i = 0; i < count; i++) {
         attr.extended[i * 2] = Util.byte2str(buf.getString());
         attr.extended[i * 2 + 1] = Util.byte2str(buf.getString());
       }
     }
   }
   return attr;
 }
Esempio n. 2
0
 /*
  * It is assumed that the argument does hold a property block - all zeros is
  * a valid (not in use) block, so even if the Bits object has been exhausted a
  * result is returned, that has inUse() return false. Also, the argument is not
  * touched.
  */
 private PropertyBlock getPropertyBlock(Buffer buffer) {
   long header = buffer.getLong();
   PropertyType type = PropertyType.getPropertyType(header, true);
   if (type == null) {
     return null;
   }
   PropertyBlock toReturn = new PropertyBlock();
   // toReturn.setInUse( true );
   int numBlocks = type.calculateNumberOfBlocksUsed(header);
   long[] blockData = new long[numBlocks];
   blockData[0] = header; // we already have that
   for (int i = 1; i < numBlocks; i++) {
     blockData[i] = buffer.getLong();
   }
   toReturn.setValueBlocks(blockData);
   return toReturn;
 }
Esempio n. 3
0
 private long getRecord(long id) {
   PersistenceWindow window = acquireWindow(id, OperationType.READ);
   try {
     Buffer buffer = window.getOffsettedBuffer(id);
     buffer.get();
     return buffer.getLong();
   } finally {
     releaseWindow(window);
   }
 }
  /**
   * Comprobar Tamaño del Fichero
   *
   * @param buf Un objeto Buffer con los datos.
   * @return lSize Tamaño del Fichero. 0 si hay un error
   */
  public static long parseFileSize(Buffer buf) throws IOException {
    long lFileSize = 0;
    try {
      // Obtener la longitud  del fichero...
      lFileSize = buf.getLong(8);

      // this.getFTP().insertStringJTextPane(" ","icono_entrada");
      // this.getFTP().insertStringJTextPane("Tamaño: "+lFileSize+newline,"entrada");

    } catch (ClusterNetInvalidParameterException e) {;
    } finally {
      return lFileSize;
    }
  }
  /**
   * Recibir Tamaño del Fichero
   *
   * @return lSize Tamaño del Fichero
   */
  private long receiveFileSize() throws IOException {
    long lFileSize = 0;
    try {
      Buffer buf = new Buffer(8);

      // Obtener la longitud del nombre del fichero...
      this.id_socketIn.read(buf.getBuffer());

      lFileSize = buf.getLong(0);

      Log.log("Size: " + lFileSize + newline, "");
    } finally {
      return lFileSize;
    }
  }