コード例 #1
0
void decideDestinationWithSuggestedObjectNameCallback(CFURLDownloadRef cfURLDownloadRef, CFStringRef objectName, const void* clientInfo)
{ 
    Download* download = downloadFromClientInfo(clientInfo);
    bool allowOverwrite;
    String destination = download->decideDestinationWithSuggestedFilename(objectName, allowOverwrite);
    if (destination.isNull())
        return;

    RetainPtr<CFStringRef> cfPath(AdoptCF, CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar*>(destination.characters()), destination.length(), kCFAllocatorNull));
    RetainPtr<CFURLRef> pathURL(AdoptCF, CFURLCreateWithFileSystemPath(0, cfPath.get(), kCFURLWindowsPathStyle, false));
    CFURLDownloadSetDestination(cfURLDownloadRef, pathURL.get(), allowOverwrite);
}
コード例 #2
0
ファイル: ProcInfo.cpp プロジェクト: ChristianHeckl/Natron
static QString
applicationFileName()
{
    static QString appFileName;

    if ( appFileName.isEmpty() ) {
        NatronCFType<CFURLRef> bundleURL( CFBundleCopyExecutableURL( CFBundleGetMainBundle() ) );
        if (bundleURL) {
            NatronCFString cfPath( CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle) );
            if (cfPath) {
                appFileName = cfPath;
            }
        }
    }

    return appFileName;
}
コード例 #3
0
ファイル: ProcInfo.cpp プロジェクト: azerupi/Natron
NATRON_NAMESPACE_ANONYMOUS_EXIT


QString
ProcInfo::applicationFilePath(const char* argv0Param)
{
#if defined(Q_OS_WIN)
    Q_UNUSED(argv0Param);
    
    //The only viable solution
    return applicationFileName();
#elif defined(Q_OS_MAC)
    //First guess this way, then use the fallback solution
    static QString appFileName;

    if ( appFileName.isEmpty() ) {
        NatronCFType<CFURLRef> bundleURL( CFBundleCopyExecutableURL( CFBundleGetMainBundle() ) );
        if (bundleURL) {
            NatronCFString cfPath( CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle) );
            if (cfPath) {
                appFileName = cfPath;
            }
        }
    }
    if ( !appFileName.isEmpty() ) {
        return appFileName;
    } else {
        return applicationFilePath_fromArgv(argv0Param);
    }
#elif defined(Q_OS_LINUX)
    // Try looking for a /proc/<pid>/exe symlink first which points to
    // the absolute path of the executable
    std::stringstream ss;
    ss << "/proc/" << getpid() << "/exe";
    std::string filename = ss.str();
    char buf[2048] = {0};
    ssize_t sizeofbuf = sizeof(char) * 2048;
    ssize_t size = readlink(filename.c_str(), buf, sizeofbuf);
    if ( (size != 0) && (size != sizeofbuf) ) {
        //detected symlink
        return QString::fromUtf8( QByteArray(buf) );
    } else {
        return applicationFilePath_fromArgv(argv0Param);
    }
#endif
}
コード例 #4
0
QT_BEGIN_NAMESPACE

/*****************************************************************************
  QCoreApplication utility functions
 *****************************************************************************/
QString qAppFileName()
{
    static QString appFileName;
    if (appFileName.isEmpty()) {
        QCFType<CFURLRef> bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
        if(bundleURL) {
            QCFString cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle));
            if(cfPath)
                appFileName = cfPath;
        }
    }
    return appFileName;
}
コード例 #5
0
ファイル: main_macx.cpp プロジェクト: relgames/keepassx
void initAppPaths(int argc,char** argv) {
    CFURLRef bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
    //assert(bundleURL);
    CFStringRef cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle));
    //assert(cfPath);
    CFIndex length = CFStringGetLength(cfPath);
    const UniChar *chars = CFStringGetCharactersPtr(cfPath);
    if (chars) {
        AppDir = QString(reinterpret_cast<const QChar *>(chars), length);
    }
    else {
        QVarLengthArray<UniChar> buffer(length);
        CFStringGetCharacters(cfPath, CFRangeMake(0, length), buffer.data());
        AppDir = QString(reinterpret_cast<const QChar *>(buffer.constData()), length);
    }
    AppDir.truncate(AppDir.lastIndexOf("/"));
    HomeDir = QDir::homePath()+"/.keepassx";
    DataDir=AppDir+"/../Resources/keepassx";
}
コード例 #6
0
ファイル: qgsserver.cpp プロジェクト: yingyuankai/QGIS
/**
 * @brief QgsServer::configPath
 * @param defaultConfigPath
 * @param parameters
 * @return config file path
 */
QString QgsServer::configPath( const QString& defaultConfigPath, const QMap<QString, QString>& parameters )
{
  QString cfPath( defaultConfigPath );
  QString projectFile = getenv( "QGIS_PROJECT_FILE" );
  if ( !projectFile.isEmpty() )
  {
    cfPath = projectFile;
  }
  else
  {
    QMap<QString, QString>::const_iterator paramIt = parameters.find( "MAP" );
    if ( paramIt == parameters.constEnd() )
    {
      QgsDebugMsg( QString( "Using default configuration file path: %1" ).arg( defaultConfigPath ) );
    }
    else
    {
      cfPath = paramIt.value();
    }
  }
  return cfPath;
}
コード例 #7
0
ファイル: qgsserver.cpp プロジェクト: SrNetoChan/Quantum-GIS
QString QgsServer::configPath( const QString &defaultConfigPath, const QString &configPath )
{
  QString cfPath( defaultConfigPath );
  QString projectFile = sSettings.projectFile();
  if ( !projectFile.isEmpty() )
  {
    cfPath = projectFile;
    QgsDebugMsg( QStringLiteral( "QGIS_PROJECT_FILE:%1" ).arg( cfPath ) );
  }
  else
  {
    if ( configPath.isEmpty() )
    {
      QgsMessageLog::logMessage( QStringLiteral( "Using default configuration file path: %1" ).arg( defaultConfigPath ), QStringLiteral( "Server" ), Qgis::Info );
    }
    else
    {
      cfPath = configPath;
      QgsDebugMsg( QStringLiteral( "MAP:%1" ).arg( cfPath ) );
    }
  }
  return cfPath;
}
コード例 #8
0
ファイル: qgsserver.cpp プロジェクト: ndavid/QGIS
/**
 * @brief QgsServer::configPath
 * @param defaultConfigPath
 * @param parameters
 * @return config file path
 */
QString QgsServer::configPath( const QString &defaultConfigPath, const QMap<QString, QString> &parameters )
{
  QString cfPath( defaultConfigPath );
  QString projectFile = sSettings.projectFile();
  if ( !projectFile.isEmpty() )
  {
    cfPath = projectFile;
    QgsDebugMsg( QString( "QGIS_PROJECT_FILE:%1" ).arg( cfPath ) );
  }
  else
  {
    QMap<QString, QString>::const_iterator paramIt = parameters.find( QStringLiteral( "MAP" ) );
    if ( paramIt == parameters.constEnd() )
    {
      QgsMessageLog::logMessage( QStringLiteral( "Using default configuration file path: %1" ).arg( defaultConfigPath ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
    }
    else
    {
      cfPath = paramIt.value();
      QgsDebugMsg( QString( "MAP:%1" ).arg( cfPath ) );
    }
  }
  return cfPath;
}