Class: Hadoop::DFS::FileInfo

Inherits:
Object
  • Object
show all
Defined in:
ext/hdfs/hdfs.c

Direct Known Subclasses

Directory, File

Defined Under Namespace

Classes: Directory, File

Instance Method Summary collapse

Instance Method Details

#block_sizeObject

Returns the block size of the file described by this object.



835
836
837
838
839
# File 'ext/hdfs/hdfs.c', line 835

VALUE HDFS_File_Info_block_size(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  return INT2NUM(file_info->mBlockSize);
}

#groupObject

Returns the group of the file described by this object.



847
848
849
850
851
# File 'ext/hdfs/hdfs.c', line 847

VALUE HDFS_File_Info_group(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  return rb_str_new(file_info->mGroup, strlen(file_info->mGroup));
}

#is_directory?Boolean

Returns True if the file described by this object is a directory; otherwise, returns False.

Returns:

  • (Boolean)


860
861
862
# File 'ext/hdfs/hdfs.c', line 860

VALUE HDFS_File_Info_is_directory(VALUE self) {
  return Qfalse;
}

#is_file?Boolean

Returns True if the file described by this object is a file; otherwise, returns False.

Returns:

  • (Boolean)


871
872
873
# File 'ext/hdfs/hdfs.c', line 871

VALUE HDFS_File_Info_is_file(VALUE self) {
  return Qfalse;
}

#last_accessObject

Returns the time of last access as an Integer representing seconds since the epoch.



890
891
892
893
894
# File 'ext/hdfs/hdfs.c', line 890

VALUE HDFS_File_Info_last_access(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  return LONG2NUM(file_info->mLastAccess);
}

#last_modifiedObject

Returns the time of last modification as an Integer representing seconds since the epoch for the file



903
904
905
906
907
# File 'ext/hdfs/hdfs.c', line 903

VALUE HDFS_File_Info_last_modified(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  return LONG2NUM(file_info->mLastMod);
}

#last_modifiedObject

Returns the time of last modification as an Integer representing seconds since the epoch.



916
917
918
919
920
# File 'ext/hdfs/hdfs.c', line 916

VALUE HDFS_File_Info_mode(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  return INT2NUM(decimal_octal(file_info->mPermissions));
}

#nameObject

Returns the name of the file as a String.



928
929
930
931
932
# File 'ext/hdfs/hdfs.c', line 928

VALUE HDFS_File_Info_name(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  return rb_str_new(file_info->mName, strlen(file_info->mName));
}

#ownerObject

Returns the owner of the file as a String.



940
941
942
943
944
# File 'ext/hdfs/hdfs.c', line 940

VALUE HDFS_File_Info_owner(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  return rb_str_new(file_info->mOwner, strlen(file_info->mOwner));
}

#replicationObject

Returns the replication factor of the file as an Integer.



952
953
954
955
956
# File 'ext/hdfs/hdfs.c', line 952

VALUE HDFS_File_Info_replication(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  return INT2NUM(file_info->mReplication);
}

#nameObject

Returns the size of the file as an Integer.



964
965
966
967
968
# File 'ext/hdfs/hdfs.c', line 964

VALUE HDFS_File_Info_size(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  return LONG2NUM(file_info->mSize);
}

#to_sObject

Returns a human-readable representation of a Hadoop::DFS::FileSystem object as a String.



977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
# File 'ext/hdfs/hdfs.c', line 977

VALUE HDFS_File_Info_to_s(VALUE self) {
  FileInfo* file_info = NULL;
  Data_Get_Struct(self, FileInfo, file_info);
  // Introspects current class, returns it as a String.
  VALUE class_string = rb_funcall(
      rb_funcall(self, rb_intern("class"), 0),
      rb_intern("to_s"), 0);
  char* output;
  VALUE string_value = rb_str_new2("");
  // If asprintf was successful, creates a Ruby String.
  if (asprintf(&output, "#<%s: %s, mode=%d, owner=%s, group=%s>",
          RSTRING_PTR(class_string), file_info->mName,
          decimal_octal(file_info->mPermissions), file_info->mOwner,
          file_info->mGroup) >= 0) {
    string_value = rb_str_new(output, strlen(output));
  }
  free(output);
  return string_value;
}