* Implemented CStudio::UpdateDialogList() function for listing saved files

dev-ui
erihel 2013-03-17 20:23:57 +01:00
parent e5aadfdaac
commit 0cd64113aa
2 changed files with 19 additions and 52 deletions

View File

@ -4353,7 +4353,7 @@ void CMainDialog::IOReadList()
filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/data.sav"; filename = m_savegameDir + "/" + m_main->GetGamerName() + "/save" + m_sceneName[0] + rankStream.str()+ "/data.sav";
// sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j); // sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j);
file = fopen(fs::path(filename).native().c_str(), "r"); file = fopen(fs::path(filename).make_preferred().c_str(), "r");
if ( file == NULL ) break; if ( file == NULL ) break;
while ( fgets(line, 500, file) != NULL ) while ( fgets(line, 500, file) != NULL )

View File

@ -1506,64 +1506,31 @@ void CStudio::UpdateDialogPublic()
void CStudio::UpdateDialogList() void CStudio::UpdateDialogList()
{ {
// TODO rewrite to multiplatform CWindow* pw;
/*CWindow* pw; CList* pl;
CList* pl; fs::path path;
long hFile; int i = 0;
struct _finddata_t fileBuffer; char time[100];
struct _finddata_t* listBuffer; char temp[100];
bool bDo;
char dir[MAX_FNAME];
char temp[MAX_FNAME];
int nbFilenames, i;
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9); pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == nullptr ) return; if ( pw == nullptr ) return;
pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST); pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST));
if ( pl == 0 ) return; if ( pl == nullptr ) return;
pl->Flush(); pl->Flush();
nbFilenames = 0; path = fs::path(SearchDirectory(false));
listBuffer = (_finddata_t*)malloc(sizeof(_finddata_t)*1000); fs::directory_iterator end_iter;
if ( fs::exists(path) && fs::is_directory(path) ) {
SearchDirectory(dir, false); for( fs::directory_iterator file(path); file != end_iter; file++) {
strcat(dir, "*"); // list all if (fs::is_regular_file(file->status()) ) {
hFile = _findfirst(dir, &fileBuffer); TimeToAscii(fs::last_write_time(file->path()), time);
if ( hFile != -1 ) sprintf(temp, "%s\t%lu \t%s", file->path().filename().c_str(), fs::file_size(file->path()), time);
{
do pl->SetName(i++, temp);
{
if ( (fileBuffer.attrib & _A_SUBDIR) == 0 )
{
listBuffer[nbFilenames++] = fileBuffer;
}
}
while ( _findnext(hFile, &fileBuffer) == 0 && nbFilenames < 1000 );
}
do // sorts all names:
{
bDo = false;
for ( i=0 ; i<nbFilenames-1 ; i++ )
{
if ( strcmp(listBuffer[i].name, listBuffer[i+1].name) > 0 )
{
fileBuffer = listBuffer[i]; // exchange i and i +1
listBuffer[i] = listBuffer[i+1];
listBuffer[i+1] = fileBuffer;
bDo = true;
} }
} }
} }
while ( bDo );
for ( i=0 ; i<nbFilenames ; i++ )
{
TimeToAscii(listBuffer[i].time_write, dir);
sprintf(temp, "%s\t%d \t%s", listBuffer[i].name, listBuffer[i].size, dir);
pl->SetName(i, temp);
}
free(listBuffer);*/
} }
// Constructs the name of the folder or open/save. // Constructs the name of the folder or open/save.