Esempio n. 1
0
void GrooveDialog::RefreshGrooveList()
{
    SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_RESETCONTENT, 0, 0);
    SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_ADDSTRING, 0, (LPARAM)__LOCALIZE("** User Groove **","sws_DLG_157"));
    WDL_DirScan dirScan;
    WDL_String searchStr(currentDir.c_str());
/* dirScan doesn't support wildcards on OSX do filtering later */
#ifdef _WIN32
    searchStr.Append( PATH_SEP "*.rgt", MAX_PATH);
    int iFind = dirScan.First(searchStr.Get(), true);
#else
    int iFind = dirScan.First(searchStr.Get());
#endif

    if (iFind == 0) {
        do {
            std::string fileName = dirScan.GetCurrentFN();
/* dirScan doesn't support wildcards on OSX so do basic filtering here */
#ifndef _WIN32
            std::string::size_type index = fileName.find_last_of(".");
            if(index == std::string::npos)
                continue;
            if(fileName.substr(index) != ".rgt")
                continue;
#endif
            std::string fileHead = fileName.substr(0, fileName.size() - 4);
            SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_ADDSTRING, 0, (LPARAM)fileHead.c_str());
        } while(!dirScan.Next());
    }
}
Esempio n. 2
0
bool
GuiAppInstance::findAndTryLoadUntitledAutoSave()
{
    if ( !appPTR->getCurrentSettings()->isAutoSaveEnabledForUnsavedProjects() ) {
        return false;
    }

    QDir savesDir( Project::autoSavesDir() );
    QStringList entries = savesDir.entryList(QDir::Files | QDir::NoDotAndDotDot);
    QStringList foundAutosaves;
    for (int i = 0; i < entries.size(); ++i) {
        const QString & entry = entries.at(i);
        QString searchStr( QLatin1Char('.') );
        searchStr.append( QString::fromUtf8(NATRON_PROJECT_FILE_EXT) );
        searchStr.append( QString::fromUtf8(".autosave") );
        int suffixPos = entry.indexOf(searchStr);
        if ( (suffixPos == -1) || entry.contains( QString::fromUtf8("RENDER_SAVE") ) ) {
            continue;
        }

        foundAutosaves << entry;
    }
    if ( foundAutosaves.empty() ) {
        return false;
    }

    QString text = tr("An auto-saved project was found with no associated project file.\n"
                      "Would you like to restore it? Clicking No will remove this auto-save.");


    appPTR->hideSplashScreen();

    StandardButtonEnum ret = Dialogs::questionDialog(tr("Auto-save").toStdString(),
                                                     text.toStdString(), false, StandardButtons(eStandardButtonYes | eStandardButtonNo),
                                                     eStandardButtonYes);
    if ( (ret == eStandardButtonNo) || (ret == eStandardButtonEscape) ) {
        Project::clearAutoSavesDir();

        return false;
    }

    for (int i = 0; i < foundAutosaves.size(); ++i) {
        const QString& autoSaveFileName = foundAutosaves[i];
        if (i == 0) {
            //Load the first one into the current instance of Natron, then open-up new instances
            if ( !getProject()->loadProject(savesDir.path() + QLatin1Char('/'), autoSaveFileName, true) ) {
                return false;
            }
        } else {
            CLArgs cl;
            AppInstance* newApp = appPTR->newAppInstance(cl, false);
            if ( !newApp->getProject()->loadProject(savesDir.path() + QLatin1Char('/'), autoSaveFileName, true) ) {
                return false;
            }
        }
    }

    return true;
} // findAndTryLoadAutoSave
Esempio n. 3
0
QString CeSdkHandler::fixPaths(QString path) const
{
    QRegExp searchStr(QLatin1String("(\\$\\(\\w+\\))"));
    QString fixedString = path;
    for (int index = fixedString.indexOf(searchStr, 0);
         index >= 0;
         index = fixedString.indexOf(searchStr, index)) {
        const QString capture = searchStr.cap(0);
        fixedString.replace(index, capture.length(), capture.toUpper());
        index += capture.length(); // don't count the zero terminator
        fixedString.insert(index, '\\'); // the configuration file lacks a directory separator for env vars
        ++index;
    }
    return fixedString;
}
Esempio n. 4
0
char* GetCheckedFileName()
{
    char        *result = NULL;
    static char *badChars = "/'\"";
    char        theBadCharMessage[] = "' '";
    char        *theBadChar = NULL;
    result = QTSSModuleUtils::GetStringAttribute(sPrefs, MODPREFIX_"dsaccessfilename", sDefaultAccessFileName);
    StrPtrLen searchStr(result);
    
    theBadChar = strpbrk(searchStr.Ptr, badChars);
    if ( theBadChar!= NULL) 
    {
        theBadCharMessage[1] = theBadChar[0];
        QTSSModuleUtils::LogErrorStr(qtssWarningVerbosity,MODPREFIX_"found invalid DS access file name in prefs");
                
        delete[] result;
        result = new char[::strlen(sDefaultAccessFileName) + 2];
        ::strcpy(result, sDefaultAccessFileName);   
    }
    return result;
}
Esempio n. 5
0
static bool recurseDumpDirectories(const char *basePath, const char *subPath, Vector<StringTableEntry> &directoryVector, S32 currentDepth, S32 recurseDepth, bool noBasePath)
{
   TempAlloc< char > search( 1024 );

   //-----------------------------------------------------------------------------
   // Compose our search string - Format : ([path]/[subpath]/*)
   //-----------------------------------------------------------------------------

   char trail = basePath[ dStrlen(basePath) - 1 ];
   char subTrail = subPath ? subPath[ dStrlen(subPath) - 1 ] : '\0';

   if( trail == '/' )
   {
      // we have a sub path and it's not an empty string
      if(  subPath  && ( dStrncmp( subPath, "", 1 ) != 0 ) )
      {
         if( subTrail == '/' )
            dSprintf(search, search.size, "%s%s*", basePath,subPath );
         else
            dSprintf(search, search.size, "%s%s/*", basePath,subPath );
      }
      else
         dSprintf( search, search.size, "%s*", basePath );
   }
   else
   {
      if(  subPath  && ( dStrncmp( subPath, "", 1 ) != 0 ) )
         if( subTrail == '/' )
            dSprintf(search, search.size, "%s%s*", basePath,subPath );
         else
            dSprintf(search, search.size, "%s%s/*", basePath,subPath );
      else
         dSprintf(search, search.size, "%s/*", basePath );
   }

#ifdef UNICODE
   TempAlloc< WCHAR > searchStr( dStrlen( search ) + 1 );
   convertUTF8toUTF16( search, searchStr, searchStr.size );
#else
   char* searchStr = search;
#endif

   backslash( searchStr );

   //-----------------------------------------------------------------------------
   // See if we get any hits
   //-----------------------------------------------------------------------------

   WIN32_FIND_DATA findData;
   HANDLE handle = FindFirstFile(searchStr, &findData);
   if (handle == INVALID_HANDLE_VALUE)
      return false;

   //-----------------------------------------------------------------------------
   // add path to our return list ( provided it is valid )
   //-----------------------------------------------------------------------------
   if( !Platform::isExcludedDirectory( subPath ) )
   {

      if( noBasePath )
      {
         // We have a path and it's not an empty string or an excluded directory
         if( ( subPath  && ( dStrncmp( subPath, "", 1 ) != 0 ) ) )
            directoryVector.push_back( StringTable->insert( subPath ) );
      }
      else
      {
         if( ( subPath  && ( dStrncmp( subPath, "", 1 ) != 0 ) ) )
         {
            char szPath [ 1024 ];
            dMemset( szPath, 0, 1024 );
            if( trail != '/' )
               dSprintf( szPath, 1024, "%s%s", basePath, subPath );
            else
               dSprintf( szPath, 1024, "%s%s", basePath, &subPath[1] );
            directoryVector.push_back( StringTable->insert( szPath ) );
         }
         else
            directoryVector.push_back( StringTable->insert( basePath ) );
      }
   }

   //-----------------------------------------------------------------------------
   // Iterate through and grab valid directories
   //-----------------------------------------------------------------------------

#ifdef UNICODE
   TempAlloc< char > fileName( 1024 );
#endif

   do
   {
      if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
      {
         // skip . and .. directories
         if (dStrcmp(findData.cFileName, TEXT( "." )) == 0 || dStrcmp(findData.cFileName, TEXT( ".." )) == 0)
            continue;

#ifdef UNICODE
         convertUTF16toUTF8( findData.cFileName, fileName, fileName.size );
#else
         char* fileName = findData.cFileName;
#endif

         // skip excluded directories
         if( Platform::isExcludedDirectory( fileName ) )
            continue;

         if( ( subPath  && ( dStrncmp( subPath, "", 1 ) != 0 ) ))
         {
            if( subTrail == '/' )
               dSprintf(search, search.size, "%s%s", subPath, fileName);
            else
               dSprintf(search, search.size, "%s/%s", subPath, fileName);
            char* child = search;

            if( currentDepth < recurseDepth || recurseDepth == -1 )
               recurseDumpDirectories(basePath, child, directoryVector, currentDepth+1, recurseDepth, noBasePath );

         }
         else
         {
            char* child;
            if( trail == '/' )
               child = fileName;
            else
            {
               dSprintf(search, search.size, "/%s", fileName);
               child = search;
            }

            if( currentDepth < recurseDepth || recurseDepth == -1 )
               recurseDumpDirectories(basePath, child, directoryVector, currentDepth+1, recurseDepth, noBasePath );
         }
      }      
   }
   while(FindNextFile(handle, &findData));

   FindClose(handle);
   return true;
}