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.



944
945
946
947
948
# File 'ext/hdfs/hdfs.c', line 944

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

#groupObject

Returns the group of the file described by this object.



956
957
958
959
960
# File 'ext/hdfs/hdfs.c', line 956

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

#is_directory?Boolean

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

Returns:

  • (Boolean)


969
970
971
# File 'ext/hdfs/hdfs.c', line 969

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)


980
981
982
# File 'ext/hdfs/hdfs.c', line 980

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.



999
1000
1001
1002
1003
# File 'ext/hdfs/hdfs.c', line 999

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



1012
1013
1014
1015
1016
# File 'ext/hdfs/hdfs.c', line 1012

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.



1025
1026
1027
1028
1029
# File 'ext/hdfs/hdfs.c', line 1025

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.



1037
1038
1039
1040
1041
# File 'ext/hdfs/hdfs.c', line 1037

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.



1049
1050
1051
1052
1053
# File 'ext/hdfs/hdfs.c', line 1049

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.



1061
1062
1063
1064
1065
# File 'ext/hdfs/hdfs.c', line 1061

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.



1073
1074
1075
1076
1077
# File 'ext/hdfs/hdfs.c', line 1073

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.



1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
# File 'ext/hdfs/hdfs.c', line 1086

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;
}