JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_SVNClient_patch
(JNIEnv *env, jobject jthis, jstring jpatchPath, jstring jtargetPath,
 jboolean jdryRun, jint jstripCount, jboolean jreverse,
 jboolean jignoreWhitespace, jboolean jremoveTempfiles, jobject jcallback)
{
  JNIEntry(SVNClient, patch);
  SVNClient *cl = SVNClient::getCppObject(jthis);
  if (cl == NULL)
    {
      JNIUtil::throwError("bad C++ this");
      return;
    }

  JNIStringHolder patchPath(jpatchPath);
  if (JNIUtil::isExceptionThrown())
    return;

  JNIStringHolder targetPath(jtargetPath);
  if (JNIUtil::isExceptionThrown())
    return;

  PatchCallback callback(jcallback);
  cl->patch(patchPath, targetPath, jdryRun ? true : false, (int) jstripCount,
            jreverse ? true : false, jignoreWhitespace ? true : false,
            jremoveTempfiles ? true : false, &callback);
}
Exemple #2
0
    void SelfUpdater::extract()
    {
        qDebug() << "SelfUpdater::extract";

        QUrl url(versionInfo["url"].toString());
        QString fileToExtract = "wpn-xm.exe";
        QString zipFile(QDir::toNativeSeparators(downloadFolder + QDir::separator() + url.fileName()));
        QString targetPath(QDir::toNativeSeparators(QCoreApplication::applicationDirPath()));

        if(!QFile(zipFile).exists()) {
            qDebug() << "[SelfUpdater] Zip File missing" << zipFile;
        }

        qDebug() << "[SelfUpdater] Extracting " << fileToExtract << "from" << zipFile << "to" << targetPath;

        // WTF? extractFile() doesn't work ???
        //qDebug() << "[SelfUpdater] Filelist:" << JlCompress::getFileList(zipFile);
        //qDebug() << JlCompress::extractFile( zipFile, fileToExtract, QDir::toNativeSeparators(downloadFolder));
        //qDebug() << JlCompress::extractFile( zipFile, fileToExtract, targetPath);

        // thanks to me, the zip file contains only the executable
        // so extractDir() is basically extractFile(), but still.... grrrr
        QStringList extractedFiles = JlCompress::extractDir(zipFile, targetPath);
        if(QFileInfo(extractedFiles.at(0)).fileName() == "wpn-xm.exe") {
            qDebug() << "[SelfUpdater] ---- Success! ----";

            if(settings->get("selfupdater/autorestart").toBool()) {
                emit notifyRestartNeeded(versionInfo);
            } else {
                askForRestart();
            }
        }
    }
JNIEXPORT void JNICALL
Java_org_apache_subversion_javahl_SVNRepos_hotcopy
(JNIEnv *env, jobject jthis, jobject jpath, jobject jtargetPath,
 jboolean jcleanLogs, jboolean jincremental, jobject jnotifyCallback)
{
  JNIEntry(SVNRepos, hotcopy);
  SVNRepos *cl = SVNRepos::getCppObject(jthis);
  if (cl == NULL)
    {
      JNIUtil::throwError(_("bad C++ this"));
      return;
    }

  File path(jpath);
  if (JNIUtil::isExceptionThrown())
    return;

  File targetPath(jtargetPath);
  if (JNIUtil::isExceptionThrown())
    return;

  ReposNotifyCallback notifyCallback(jnotifyCallback);

  cl->hotcopy(path, targetPath, jcleanLogs ? true : false,
              jincremental ? true : false,
              jnotifyCallback != NULL ? &notifyCallback : NULL);
}
Exemple #4
0
bool DatabaseSettingsWidget::checkDatabasePath()
{
    QString dbFolder = databasePath();
    qCDebug(DIGIKAM_DATABASE_LOG) << "Database directory is : " << dbFolder;

    if (dbFolder.isEmpty())
    {
        QMessageBox::information(qApp->activeWindow(), qApp->applicationName(),
                                i18n("You must select a folder for digiKam to "
                                     "store information and metadata in a database file."));
        return false;
    }

    QDir targetPath(dbFolder);

    if (!targetPath.exists())
    {
        int rc = QMessageBox::question(qApp->activeWindow(), i18n("Create Database Folder?"),
                                    i18n("<p>The folder to put your database in does not seem to exist:</p>"
                                         "<p><b>%1</b></p>"
                                         "Would you like digiKam to create it for you?", dbFolder));

        if (rc == QMessageBox::No)
        {
            return false;
        }

        if (!targetPath.mkpath(dbFolder))
        {
            QMessageBox::information(qApp->activeWindow(), i18n("Create Database Folder Failed"),
                                    i18n("<p>digiKam could not create the folder to host your database file.\n"
                                         "Please select a different location.</p>"
                                         "<p><b>%1</b></p>", dbFolder));
            return false;
        }
    }

    QFileInfo path(dbFolder);

#ifdef _WIN32
    // Work around bug #189168
    QTemporaryFile temp;
    temp.setFileTemplate(dbFolder + QLatin1String("XXXXXX"));

    if (!temp.open())
#else
    if (!path.isWritable())
#endif
    {
        QMessageBox::information(qApp->activeWindow(), i18n("No Database Write Access"),
                                i18n("<p>You do not seem to have write access "
                                     "for the folder to host the database file.<br/>"
                                     "Please select a different location.</p>"
                                     "<p><b>%1</b></p>", dbFolder));
        return false;
    }

    return true;
}
Exemple #5
0
void FileTransfer::downloadFile(const std::string filepath)
{
    std::string sourcePath(Plugin::GIT_CACHE_DIR);
    sourcePath.append("/").append(filepath);
    Process::Args args;
    args.push_back(filepath);
    // TODO: Change this name
    std::string targetPath("~/keshig-storage/");
    targetPath.append(filepath);
    Poco::ProcessHandle ph = Process::launch("scp", args, 0, 0, 0); 
    if (ph.wait() != 0) throw new Poco::RuntimeException("Failed to upload file");
}
Exemple #6
0
TInt CMsvMove::SetupStoreCopy()
//
//
//
	{
	TFileName storeName;
	iServer.GetEntryName(iCurrentEntry->Id(), storeName, EFalse);

	TFileName targetPath(*iTargetPath);
	TBuf<1> dir;
	dir.NumFixedWidth(iCurrentEntry->Id()&0xf, EHex, 1);
	targetPath.Append(dir);
	_LIT(KDirSep,"\\");
	targetPath.Append(KDirSep);
	iServer.FileSession().MkDirAll(targetPath); // ignore errors, if it failed to create the directory the next line will fail
	return iFileMan->Copy(storeName, targetPath, CFileMan::EOverWrite, iStatus);
	}
Exemple #7
0
int FileMgr::removeDir(const char *targetDir) {
    if (auto dir = DirectoryEnumerator(targetDir)) {
        while (auto const ent = dir.readEntry()) {
            std::string targetPath(std::string(targetDir) + '/' + ent);
            if (!isDirectory(targetPath)) {
                FileMgr::removeFile(targetPath.c_str());
            }
            else {
                FileMgr::removeDir(targetPath.c_str());
            }
        }
        dir.close();
        FileMgr::removeFile(targetDir);
/*
        int status = FileMgr::removeFile(targetDir);
          int stuff = errno;
          char *err = std::strerror(errno);
          int x = stuff;
*/
    }
    return 0;
}
Exemple #8
0
void CMsvMove::StartL(TMsvId aId, TMsvId aTarget, TRequestStatus& aObserverStatus)
//
//
//
	{
	// Fail now if the index says it's not available
	User::LeaveIfError(iServer.IndexAdapter().ErrorState());
	Reset();

	// check the source and target exists and which service they are under
	User::LeaveIfError(iServer.IndexAdapter().OwningService(aId, iSourceService));
	User::LeaveIfError(iServer.IndexAdapter().OwningService(aTarget, iTargetService));

#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
	// Movement of entries across drives not supported.
	if(GetDriveId(aId) != GetDriveId(aTarget))
		{
		User::Leave(KErrNotSupported);
		}
#endif		// #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)

	// get the index entry
	iSourceId = aId;
	iServer.IndexAdapter().GetEntry(iSourceId, iCurrentEntry); // error ignored as entry exists
	iParentId = iCurrentEntry->Parent();
	iTargetId = aTarget;
	iDescendents->AppendL(iSourceId);
	iNextDescendent=1;

	__ASSERT_DEBUG(iCurrentEntry->Parent()!=iTargetId, PanicServer(EMsvMtmMovingToSameParent));

	// check if the entry has children
	if (iCurrentEntry->Owner())
		{
		// check for moving into a descendent
		TBool descendent;
		iServer.IndexAdapter().IsADescendent(aId, aTarget, descendent); // error ignored as both entry exists
		if (descendent)
			User::Leave(KErrArgument);

		// get id of all the descendents
		User::LeaveIfError(iServer.IndexAdapter().ExpandSelectionRecursively(*iDescendents));
		}

	// check all the entries can be moved
	CheckEntriesL();

	// determine whether the store/files actually need copying
	iState = (iSourceService==iTargetService ? EIndex : EFolder);

	// set up the file copying
	if (iState!=EIndex)
		{
		TFileName targetPath(iServer.Context().MessageFolder());
		MsvUtils::ConstructEntryName(iTargetService, iTargetService, targetPath, MsvUtils::EPath);

		iTargetPath = targetPath.AllocL();
		iServer.FileSession().MkDirAll(targetPath);
		User::LeaveIfError(iServer.IndexAdapter().GetEntry(iDescendents->At(0), iCurrentEntry));

		// make sure the first step is valid
		TInt result = MsvUtils::HasDirectory(iServer.FileSession(), iServer.Context().MessageFolder(), iSourceService, iCurrentEntry->Id());
		User::LeaveIfError(result);

		if (!result)
			FindNextStep();
		}

	StartNextStep();

	iObserverStatus = &aObserverStatus;
	*iObserverStatus = KRequestPending;
	}
Exemple #9
0
	void Host::CopyModuleAppResources(std::string& modulePath)
	{
		this->logger->Trace("CopyModuleAppResources: %s", modulePath.c_str());
		std::string appDir = this->application->path;
		Path appPath(this->application->path);

		try
		{
			Path moduleDir(modulePath);
			moduleDir = moduleDir.parent();
			std::string mds(moduleDir.toString());

			const char* platform = this->GetPlatform();
			std::string resources_dir = FileUtils::Join(mds.c_str(), "AppResources", NULL);
			std::string plt_resources_dir = FileUtils::Join(resources_dir.c_str(), platform, NULL);
			std::string all_resources_dir = FileUtils::Join(resources_dir.c_str(), "all", NULL);
			File platformAppResourcesDir(plt_resources_dir);
			File allAppResourcesDir(all_resources_dir);

			if (platformAppResourcesDir.exists()
				&& platformAppResourcesDir.isDirectory())
			{

				std::vector<File> files;
				platformAppResourcesDir.list(files);
				for (size_t i = 0; i < files.size(); i++) 
				{
					File f = files.at(i);
					Path targetPath(appPath, Path(Path(f.path()).getBaseName()));
					File targetFile(targetPath);
					this->logger->Trace("target: %s", targetFile.path().c_str());
					if (!targetFile.exists())
					{
						this->logger->Trace("Copying : %s to %s", f.path().c_str(), appDir.c_str());
						f.copyTo(appDir);
					}
					else
					{
						this->logger->Trace("SKIP Copying : %s to %s", f.path().c_str(), appDir.c_str());
					}
				}
			}

			if (allAppResourcesDir.exists()
				&& allAppResourcesDir.isDirectory())
			{
				std::vector<File> files;
				allAppResourcesDir.list(files);
				for (size_t i = 0; i < files.size(); i++) 
				{
					File f = files.at(i);
					Path targetPath(appPath, Path(Path(f.path()).getBaseName()));
					File targetFile(targetPath);
					this->logger->Trace("target: %s", targetFile.path().c_str());
					if (!targetFile.exists())
					{
						this->logger->Trace("Copying: %s to %s", f.path().c_str(), appDir.c_str());
						f.copyTo(appDir);
					}
					else
					{
						this->logger->Trace("SKIP Copying : %s to %s", f.path().c_str(), appDir.c_str());
					}
				}
			}
		}
		catch (Poco::Exception &exc)
		{
			// Handle..
		}
	}
Exemple #10
0
bool CollectionPage::checkRootAlbum(QString& rootAlbumFolder)
{
    rootAlbumFolder = d->rootAlbumPathRequester->lineEdit()->text();
    qCDebug(DIGIKAM_GENERAL_LOG) << "Root album is : " << rootAlbumFolder;

    if (rootAlbumFolder.isEmpty())
    {
        QMessageBox::information(this, qApp->applicationName(), 
                                 i18n("You must select a folder for digiKam to "
                                      "use as the root album. All of your images will go there."));
        return false;
    }

#ifndef _WIN32

    if (!QDir::isAbsolutePath(rootAlbumFolder))
    {
        rootAlbumFolder.prepend(QDir::homePath());
    }

#endif

/*
    if (QUrl::fromLocalFile(rootAlbumFolder).equals(QUrl::fromLocalFile(QDir::homePath()), QUrl::CompareWithoutFragment))
    {
        QMessageBox::information(this, qApp->applicationName(), 
                                 i18n("digiKam will not use your home folder as the "
                                      "root album. Please select another location."));
        return false;
    }
*/

    QDir targetPath(rootAlbumFolder);

    if (!targetPath.exists())
    {
        int rc = QMessageBox::question(this, i18n("Create Root Album Folder?"),
                                       i18n("<p>The folder to use as the root album path does not exist:</p>"
                                                 "<p><b>%1</b></p>"
                                                 "Would you like digiKam to create it for you?",
                                                 rootAlbumFolder));

        if (rc == QMessageBox::No)
        {
            return false;
        }

        if (!targetPath.mkpath(rootAlbumFolder))
        {
            QMessageBox::information(this, i18n("Create Root Album Folder Failed"),
                                     i18n("<p>digiKam could not create the folder to use as the root album.\n"
                                          "Please select a different location.</p>"
                                          "<p><b>%1</b></p>", rootAlbumFolder));
            return false;
        }
    }

    QFileInfo path(rootAlbumFolder);

#ifdef _WIN32
    // Work around bug #189168
    QTemporaryFile temp;
    temp.setFileTemplate(rootAlbumFolder + QLatin1String("XXXXXX"));

    if (!temp.open())
#else
    if (!path.isWritable())
#endif
    {
        QMessageBox::information(this, qApp->applicationName(), 
                                 i18n("You do not seem to have write access for the folder "
                                      "selected to be the root album.\n"
                                      "Warning: Without write access, items cannot be edited."));
    }

    return true;
}
Exemple #11
0
void ProjectGenerator::OnGenerateButton(const nuiEvent& rEvent)
{
  nglString source = mpNuiSource->GetText();
  nglString target = mpProjectTarget->GetText();
  source.Trim();
  target.Trim();
  
  if ((source == nglString::Null) || (target == nglString::Null))
  {
    nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), _T("Project Creator"), _T("source and target information can't be empty!"), eMB_OK);
    pMessageBox->QueryUser();   
    rEvent.Cancel();
    return;
  }

  nglPath sourcePath(source);
  if (!sourcePath.Exists())
  {
    nglString msg;
    msg.Format(_T("the nui source directory '%ls' does not exist!"), sourcePath.GetChars());
    nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK);
    pMessageBox->QueryUser();     
    rEvent.Cancel();
    return;
  }
  
  if (!mNuiCheckProjectFile || !mNuiCheckTools)
  {
    nglString msg;
    msg.Format(_T("Parts of nui could not be found.\nCheck the nui source directory or checkout the complete nui sources from libnui.net!"));
    nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK);
    pMessageBox->QueryUser();
    rEvent.Cancel();
    return;        
  }

  mNuiSourcePath = source;
  mProjectTargetPath = target;
  nglPath path = nglPath(target);
  mProjectName = path.GetNodeName();

  nglPath targetPath(target);
  nglString xcodeproj = mProjectName + _T(".xcodeproj");
  targetPath += nglPath(xcodeproj);
  if (targetPath.Exists())
  {
    nglString msg;
    msg.Format(_T("the following project exists already!\n'%ls'"), targetPath.GetChars());
    nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK);
    pMessageBox->QueryUser();     
    rEvent.Cancel();
    return;
  }
  
  
  GetPreferences().Save();
  
  Make();
  
  rEvent.Cancel();
}
STDMETHODIMP PartCoverConnector2::StartTarget(
    BSTR p_targetPath, 
    BSTR p_targetWorkingDir, 
    BSTR p_targetArguments,
    VARIANT_BOOL redirectOutput,
	IConnectorActionCallback* callback)
{
    HRESULT hr;
    _bstr_t targetPath(p_targetPath);
    _bstr_t targetWorkingDir(p_targetWorkingDir);
    _bstr_t targetArguments(p_targetArguments);

    if (targetWorkingDir.length() == 0 || targetPath.length() == 0 )
        return E_INVALIDARG;

	if(callback != 0 ) callback->OpenMessagePipe();

    // init message center 
    if(FAILED(hr = m_center.Open()))
        return hr;

	if(callback != 0 ) callback->TargetSetEnvironmentVars();

    targetArguments = _bstr_t("\"") + targetPath + _bstr_t("\" ") + targetArguments;

    // get current working dir and settings
    StringMap env = ParseEnvironment();
    env[_T("Cor_Enable_Profiling")] = _T("1");
    env[_T("Cor_Profiler")] = _T("{") _T(DRIVER_CORPROFILER_GUID) _T("}");
    env[OPTION_MESSOPT] = m_center.getId();

    if (m_driverLogging > 0)
	{
		DynamicArray<TCHAR> curBuffer(5);
        _stprintf_s(curBuffer, curBuffer.size(), _T("%d"), m_driverLogging);
        env[OPTION_VERBOSE] = curBuffer;
	}

	if (m_useFileLogging) {
        DWORD curLength = ::GetCurrentDirectory(0, NULL);
        DynamicArray<TCHAR> curBuffer(curLength + 25);
        if (curLength = ::GetCurrentDirectory(curLength + 1, curBuffer)) 
		{
            _stprintf_s(curBuffer + curLength, 25, DRIVER_LOG_FILENAME);
            env[OPTION_LOGFILE] = curBuffer;

			m_logFile = curBuffer;
        }
    }

	if (m_usePipeLogging) {
        env[OPTION_LOGPIPE] = _T("1");
    }

    // copy old and new env settings
    LPTSTR new_env = CreateEnvironment(env);

	if(callback != 0 ) callback->TargetCreateProcess();

    // extract 
    STARTUPINFO si;
    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);

    if (redirectOutput == VARIANT_TRUE) {
        si.dwFlags = STARTF_USESTDHANDLES;
        si.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);
        si.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
        si.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);
    }

    ZeroMemory(&pi, sizeof(pi));

    DynamicArray<TCHAR> args(targetArguments.length() + 1);
    _tcscpy_s(args, targetArguments.length() + 1, targetArguments);

    BOOL created = ::CreateProcess(
                        NULL, // Application
                        args, // command line
                        NULL, // lpProcessAttributes,
                        NULL, // lpThreadAttributes,
                        redirectOutput == VARIANT_TRUE ? TRUE : FALSE, // bInheritHandles,
#ifdef _UNICODE
                        CREATE_UNICODE_ENVIRONMENT |
#endif
                        (redirectOutput == VARIANT_TRUE ? 0 : CREATE_NEW_CONSOLE),
                        new_env,
                        targetWorkingDir,
                        &si,
                        &pi );

    // clear environment
    FreeEnvironment(new_env);
    
    if (!created)
        return HRESULT_FROM_WIN32( ::GetLastError() );

	if(callback != 0 ) callback->TargetWaitDriver();

    if (FAILED(hr = m_center.WaitForClient()))
        return hr;

	if(callback != 0 ) callback->DriverConnected();

	struct Starter : ITransferrableVisitor {
		IConnectorActionCallback* m_callback;
	public:
		bool readyToGo;
		Starter(IConnectorActionCallback* callback) : m_callback(callback), readyToGo(false) {}

		void on(MessageType type) { if (Messages::C_RequestStart == type) readyToGo = true; }
		void on(FunctionMap& value) {}
		void on(Rules& value) {}
		void on(InstrumentResults& value) {}
		void on(LogMessage& value) { if (m_callback != 0) m_callback->LogMessage(value.getThreadId(), value.getTicks(), _bstr_t(value.getMessage().c_str())); }
	} messageVisitor(callback);

	ITransferrable* message;
	while(SUCCEEDED(m_center.Wait(message)))
	{
		message->visit(messageVisitor);
		destroy(message);
		if (messageVisitor.readyToGo) break;
	}

	if (!messageVisitor.readyToGo)
	{
		ATLTRACE("PartCoverConnector2::StartTarget - C_RequestStart wait error");
		return E_ABORT;
	}

	if(callback != 0 ) callback->DriverSendRules();

	m_center.Send(m_rules);
	m_center.Send(Messages::Message<Messages::C_EndOfInputs>());

	if(callback != 0 ) callback->DriverWaitEoIConfirm();

	messageVisitor.readyToGo = false;
	while(SUCCEEDED(m_center.Wait(message)))
	{
		message->visit(messageVisitor);
		destroy(message);

		if (messageVisitor.readyToGo) break;
	}

	return true;
}
bool Link::targetExists()
{
    return QFileInfo(targetPath()).exists();
}