# HG changeset patch # User insilmaril # Date 1193046603 0 # Node ID 84c73902f7273715ef6bb0c37e80e787b4013e15 # Parent 12e4596e7bb73e82d59b7313609b10554956cf89 Various patches: Better windows support, branch sorting, Freedesktop support diff -r 12e4596e7bb7 -r 84c73902f727 exports.cpp --- a/exports.cpp Mon Oct 22 09:50:03 2007 +0000 +++ b/exports.cpp Mon Oct 22 09:50:03 2007 +0000 @@ -14,7 +14,7 @@ { indentPerDepth=" "; bool ok; - tmpDir.setPath (makeUniqueDir(ok,"/tmp/vym-export-XXXXXX")); + tmpDir.setPath (makeTmpDir(ok,"vym-export")); if (!tmpDir.exists() || !ok) QMessageBox::critical( 0, QObject::tr( "Error" ), QObject::tr("Couldn't access temporary directory\n")); diff -r 12e4596e7bb7 -r 84c73902f727 file.cpp --- a/file.cpp Mon Oct 22 09:50:03 2007 +0000 +++ b/file.cpp Mon Oct 22 09:50:03 2007 +0000 @@ -1,3 +1,4 @@ +#include #include #include #include @@ -7,6 +8,11 @@ #include "file.h" #include "process.h" +// Avoid full inclusion of io.h by just defining mktemp's prototype here. +#if defined(Q_OS_WIN32) +extern "C" char *_mktemp(char *fmt); +#include +#endif QString maskPath(QString p) { @@ -95,7 +101,7 @@ QMessageBox::Warning, QMessageBox::Yes , QMessageBox::Cancel | QMessageBox::Default, - QMessageBox::QMessageBox::NoButton ); + QMessageBox::NoButton ); mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") ); mb.setButtonText( QMessageBox::No, QObject::tr("Cancel")); @@ -112,11 +118,29 @@ return true; } +QString makeTmpDir (bool &ok, QString prefix) +{ + bool b; + QString path=makeUniqueDir (b,QDir::tempPath()+"/"+prefix+"-XXXXXX"); + ok=b; + return path; +} + +bool isInTmpDir(QString fn) +{ + QString temp=QDir::tempPath(); + int l=temp.length(); + return fn.left(l)==temp; +} + QString makeUniqueDir (bool &ok,QString s) { - // Create unique directory e.g. s="/tmp/vym-XXXXXX" + // Create unique directory e.g. for s="/tmp/vym-XXXXXX" - // Convert QString to string first + // Convert Separators + s=QDir::convertSeparators(s); + + // Convert QString to string ok=true; char *p; int bytes=s.length(); @@ -125,7 +149,13 @@ for (i=0;isetWorkingDirectory (zipDir.path()); @@ -317,6 +348,45 @@ } } } +#else + // Do this process creation using Win32 API. + //! Create process. + PROCESS_INFORMATION piProcInfo; + STARTUPINFO siStartInfo; + + // Initialize members of the PROCESS_INFORMATION structure. + ::ZeroMemory( &piProcInfo, sizeof(PROCESS_INFORMATION) ); + + // Set up members of the STARTUPINFO structure. + ::ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) ); + siStartInfo.cb = sizeof(STARTUPINFO); + + // Create command line. + QString argv("unzip -o "); + argv.append(QDir::convertSeparators(zipName)); + argv.append(" -d "); + argv.append(QDir::convertSeparators(zipDir.path())); + + // Create the child process. + if( !::CreateProcess(NULL, + (LPWSTR)argv.unicode(), // command line + NULL, // process security attributes + NULL, // primary thread security attributes + TRUE, // handles are inherited + 0, // creation flags + NULL, // use parent's environment + NULL, // use parent's current directory + &siStartInfo, // STARTUPINFO pointer + &piProcInfo) ) // receives PROCESS_INFORMATION + { + err = aborted; + } + else + { + // Wait for it to finish. + ::WaitForSingleObject( piProcInfo.hProcess, 10000 ); + } +#endif return err; }