std::string wgfc::GetDirectoryInfo (const wxFileName &fname) { infoFileSize_ = 0; infoFileCount_ = 0; infoDirCount_ = 0; std::string str("Directory is: "); wxDateTime crtm, mdtm, actm; wxDir dir (fname.GetFullPath()); if (!dir.IsOpened()) { wxFileName fn (fname.GetFullPath()); str = "File is: "; str += fname.GetFullPath().c_str() + "\n\n"; wxDateTime crtm, mdtm, actm; std::string u8s = fname.GetFullPath().utf8_str().data(); wxString crstr (OSXFileAttributes::getFileCreationDate(u8s).c_str(), wxConvUTF8); str += std::string("Created on: ") + crstr + "\n"; if (fname.GetTimes (&actm, &mdtm, &crtm)) { wxString mdstr = mdtm.Format ("%a %b %d %Y %X"); str += std::string("Modified on: ") + mdstr + "\n"; } //return ""; } else { getInfo (fname); str += fname.GetFullPath().c_str() + "\n\n"; // sys/time.h //int utimes(const char *, const struct timeval *); //#include <sys/time.h> //int futimes(int fildes, const struct timeval times[2]); //int utimes(const char *path, const struct timeval times[2]); std::string u8s = fname.GetFullPath().utf8_str().data(); wxString crstr (OSXFileAttributes::getFileCreationDate(u8s).c_str(), wxConvUTF8); str += std::string("Created on: ") + crstr + "\n"; if (fname.GetTimes (&actm, &mdtm, &crtm)) { wxString mdstr = mdtm.Format ("%a %b %d %Y %X"); str += std::string("Modified on: ") + mdstr + "\n"; } wxString sizestr; sizestr << "Total number of subdirectories: " << infoDirCount_ << "\n" << "Total number of files: " << infoFileCount_ << "\n" << "Total size: " << getSizeString(infoFileSize_) << "\n"; str += sizestr.c_str(); } return str; }
//sets IsPresent if the file is valid, and derived properties (filename, formatted, size, etc) bool EnumerateMemoryCard( McdSlotItem& dest, const wxFileName& filename, const wxDirName basePath ) { dest.IsFormatted = false; dest.IsPresent = false; const wxString fullpath( filename.GetFullPath() ); if( !filename.FileExists() ) return false; DevCon.WriteLn( fullpath ); wxFFile mcdFile( fullpath ); if( !mcdFile.IsOpened() ) return false; // wx should log the error for us. if( mcdFile.Length() < (1024*528) ) { Console.Warning( "... MemoryCard appears to be truncated. Ignoring." ); return false; } dest.IsPresent = true; dest.Filename = filename; if( filename.GetFullPath() == (basePath+filename.GetFullName()).GetFullPath() ) dest.Filename = filename.GetFullName(); dest.SizeInMB = (uint)(mcdFile.Length() / (1024 * 528 * 2)); dest.IsFormatted = IsMcdFormatted( mcdFile ); filename.GetTimes( NULL, &dest.DateModified, &dest.DateCreated ); return true; }
int Test_Date(wxString FileName) { FN.Assign(FileName); if (!FN.FileExists()) { ToShow+=FileName; ToShow+=__T(" does not exist"); return -1; } if (!FN.GetTimes(&Access, NULL, NULL)) { ToShow+=__T("Error getting date of "); ToShow+=FileName; return -1; } wxTimeSpan TS=wxDateTime::Now()-Access; if (TS.GetWeeks()>0 || TS.GetDays()>0 || TS.GetHours()>0 || TS.GetMinutes()>0) { ToShow+=FileName; ToShow+=__T(" is old : was compiled"); ToShow+=TS.Format().c_str(); ToShow+=__T(" ago\r\n"); } return 0; }
//sets IsPresent if the file is valid, and derived properties (filename, formatted, size, etc) bool EnumerateMemoryCard( McdSlotItem& dest, const wxFileName& filename, const wxDirName basePath ) { dest.IsFormatted = false; dest.IsPresent = false; dest.IsPSX = false; dest.Type = MemoryCardType::MemoryCard_None; const wxString fullpath( filename.GetFullPath() ); //DevCon.WriteLn( fullpath ); if ( filename.FileExists() ) { // might be a memory card file wxFFile mcdFile( fullpath ); if ( !mcdFile.IsOpened() ) { return false; } // wx should log the error for us. wxFileOffset length = mcdFile.Length(); if( length < (1024*528) && length != 0x20000 ) { Console.Warning( "... MemoryCard appears to be truncated. Ignoring." ); return false; } dest.SizeInMB = (uint)( length / ( 1024 * 528 * 2 ) ); if ( length == 0x20000 ) { dest.IsPSX = true; // PSX memcard; dest.SizeInMB = 1; // MegaBIT } dest.Type = MemoryCardType::MemoryCard_File; dest.IsFormatted = IsMcdFormatted( mcdFile ); filename.GetTimes( NULL, &dest.DateModified, &dest.DateCreated ); } else if ( filename.DirExists() ) { // might be a memory card folder wxFileName superBlockFileName( fullpath, L"_pcsx2_superblock" ); if ( !superBlockFileName.FileExists() ) { return false; } wxFFile mcdFile( superBlockFileName.GetFullPath() ); if ( !mcdFile.IsOpened() ) { return false; } dest.SizeInMB = 0; dest.Type = MemoryCardType::MemoryCard_Folder; dest.IsFormatted = IsMcdFormatted( mcdFile ); superBlockFileName.GetTimes( NULL, &dest.DateModified, &dest.DateCreated ); } else { // is neither return false; } dest.IsPresent = true; dest.Filename = filename; if( filename.GetFullPath() == (basePath+filename.GetFullName()).GetFullPath() ) dest.Filename = filename.GetFullName(); return true; }