00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <string>
00019 #include <algorithm>
00020 #include <cctype>
00021 #include <string.h>
00022
00023 #include "ObjectInfo.h"
00024
00025 ObjectInfo::ObjectInfo()
00026 {
00027
00028 this->name = "";
00029 this->path = "";
00030 this->fullPath = "";
00031 this->type = 0;
00032 this->permission = 0;
00033 this->owner = "";
00034 this->group = "";
00035 this->size = 0;
00036 memset( &this->time, 0, sizeof( this->time ) );
00037 this->VideoRate = 0;
00038 this->md5sum[0] = '\0';
00039 }
00040
00041 bool ObjectInfo::operator<( ObjectInfo obj ) const
00042 {
00043 string this_fullpath = ((ObjectInfo *)this)->getFullPath();
00044 string obj_fullpath = obj.getFullPath();
00045
00046
00047
00048
00049
00050 transform( this_fullpath.begin(), this_fullpath.end(),
00051 this_fullpath.begin(), ( int(*)(int) ) tolower );
00052 transform( obj_fullpath.begin(), obj_fullpath.end(),
00053 obj_fullpath.begin(), ( int(*)(int) ) tolower );
00054 return( this_fullpath < obj_fullpath );
00055 }
00056 void ObjectInfo::setName( string name )
00057 {
00058 this->name = name;
00059 }
00060
00061 void ObjectInfo::setPath( string path )
00062 {
00063 this->path = path;
00064 }
00065
00066 void ObjectInfo::setFullPath( string fullPath )
00067 {
00068 this->fullPath = fullPath;
00069 }
00070
00071 void ObjectInfo::setType( short type )
00072 {
00073 this->type = type;
00074 }
00075
00076 void ObjectInfo::setPermission( short permission )
00077 {
00078 this->permission = permission;
00079 }
00080
00081 void ObjectInfo::setOwner( string owner )
00082 {
00083 this->owner = owner;
00084 }
00085
00086 void ObjectInfo::setGroup( string group )
00087 {
00088 this->group = group;
00089 }
00090
00091 void ObjectInfo::setSize( RioObjectSize size )
00092 {
00093 this->size = size;
00094 }
00095
00096 void ObjectInfo::setTime( AccessTime time )
00097 {
00098 memcpy( (void *) &(this->time), (void *) &time, sizeof( AccessTime ) );
00099 }
00100
00101 void ObjectInfo::setMd5sum( char *md5sum )
00102 {
00103 if( md5sum == NULL )
00104 this->md5sum[0] = '\0';
00105 else
00106 strcpy( this->md5sum, md5sum );
00107 }
00108
00109 string ObjectInfo::getName()
00110 {
00111 return name;
00112 }
00113
00114 string ObjectInfo::getPath()
00115 {
00116 return path;
00117 }
00118
00119 string ObjectInfo::getFullPath()
00120 {
00121 return fullPath;
00122 }
00123
00124 short ObjectInfo::getType()
00125 {
00126 return type;
00127 }
00128
00129 short ObjectInfo::getPermission()
00130 {
00131 return permission;
00132 }
00133
00134 string ObjectInfo::getOwner()
00135 {
00136 return owner;
00137 }
00138
00139 string ObjectInfo::getGroup()
00140 {
00141 return group;
00142 }
00143
00144 RioObjectSize ObjectInfo::getSize()
00145 {
00146 return size;
00147 }
00148
00149 AccessTime ObjectInfo::getTime()
00150 {
00151 return time;
00152 }
00153
00154 void ObjectInfo::getMd5sum( char * md5sum )
00155 {
00156 strcpy( md5sum, this->md5sum );
00157 }
00158
00159
00160
00161
00162 string ObjectInfo::getFullName()
00163 {
00164 string fullname;
00165
00166 fullname = path;
00167 fullname += name;
00168
00169 return fullname;
00170 }
00171
00172
00173
00174
00175
00176
00177 bool ObjectInfo::isDir()
00178 {
00179 return ( ( this->type == FILE_TYPE_DIRECTORY ) ||
00180 ( this->type == FILE_TYPE_DIR_LINK )
00181 );
00182 }
00183
00184
00185
00186
00187
00188 bool ObjectInfo::isHidden()
00189 {
00190 bool hidden = false;
00191
00192 if( ( name.length() > 0 ) && ( name.at( 0 ) == '.' ) )
00193 hidden = true;
00194
00195 return hidden;
00196 }
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 void ObjectInfo::setNames( const char *objectName, const char *fullPath )
00207 {
00208 char *lastName, *freelastName;
00209 char *path;
00210
00211 freelastName = strdup( objectName );
00212 lastName = strrchr( freelastName, '/' );
00213 path = strdup( objectName );
00214
00215 if( ( lastName != NULL ) && strcmp( objectName, "/" ) )
00216 {
00217 lastName++;
00218 this->name = lastName;
00219
00220 lastName = strrchr( path, '/' );
00221 lastName++;
00222 *lastName = '\0';
00223 this->path = path;
00224 }
00225 else
00226 {
00227 this->name = objectName;
00228 this->path.clear();
00229 }
00230
00231 if( ( fullPath != NULL ) &&
00232 ( (int)strlen( fullPath ) > 0 ) &&
00233 ( objectName[0] != '/' )
00234 )
00235 {
00236 this->fullPath = strdup( fullPath );
00237
00238 if( strcmp( fullPath, "/" ) != 0 )
00239 this->fullPath += "/";
00240
00241 this->fullPath += strdup( objectName );
00242 }
00243 else
00244 this->fullPath = strdup( objectName );
00245
00246 free( freelastName );
00247 free( path );
00248 }
00249
00250
00251
00252
00253
00254 unsigned int ObjectInfo::getVideoRate()
00255 {
00256 return VideoRate;
00257 }
00258
00259
00260 void ObjectInfo::setVideoRate( unsigned int VideoRate )
00261 {
00262 this->VideoRate = VideoRate;
00263 }