Пример #1
0
	void ImportLanguageReference()
	{
		m_lang.clear();
		boost::filesystem::path binFolder;
		GetProgramFolder(binFolder);
		boost::filesystem::path path = binFolder / stringToPath(LANGREFFILE_CSV);
		boost::filesystem::path xml_path = binFolder / stringToPath(ReferenceFileName().GetString());

		CUnicodeFile file;
		if (file.Open(pathToString(path).c_str()))
		{
			std::_tstring data;
			file.Read(data);

			typedef std::vector<std::_tstring> split_vector_type;
			split_vector_type SplitVec; 
			boost::algorithm::split(SplitVec, data, boost::algorithm::is_any_of("\r\n"), boost::algorithm::token_compress_on);

			for (split_vector_type::const_iterator itr = SplitVec.begin(); itr != SplitVec.end(); ++itr)
			{
				std::_tstring line = *itr;
				if (line.length())
				{
					std::vector<std::_tstring> fields;
					DecodeCSV(line, fields);
					m_lang.push_back(fields);
				}
			}
		}
		save(m_lang, xml_path.string().c_str());
	}
Пример #2
0
//bool CBuilderDlg::DoFileOpen(const CString & sPathName) 
//{
//  Help Alligning with BuilderDlg COmpare
//}
bool CAttributeDlg::DoSave(bool attrOnly)
{
    CWaitCursor wait;
    CString ecl;
    m_view.GetText(ecl);

    CString id = m_attribute->GetID();
    CString user = m_attribute->GetModifiedBy();
    CString module = m_attribute->GetModuleQualifiedLabel();
    CString attributeName = m_attribute->GetLabel();
    IAttributeType* attrType = m_attribute->GetType();

    CBookmarksFrame * pFrame = GetBookmarksFrame();
    if (pFrame)
    {
        pFrame->ParseBookmarksEcl((LPCTSTR)ecl, (LPCTSTR)user, (LPCTSTR)id, (LPCTSTR)module, (LPCTSTR)attributeName, attrType);
    }

    if (m_attribute->SetText(ecl))
    {
        //  Save local item for history  ---
        boost::filesystem::path path;
        GetIConfig(QUERYBUILDER_CFG)->GetEnvironmentFolder(path);
        path /= stringToPath(m_attribute->GetModuleQualifiedLabel());
        boost::filesystem::create_directories(path);
        path /= stringToPath(m_attribute->GetLabel());
        boost::filesystem::create_directories(path);

        CTime t = CTime::GetCurrentTime();
        std::_tstring now = t.FormatGmt(_T("%Y-%m-%dT%H_%M_%SZ.ecl"));
        path /= stringToPath(now);

        CUnicodeFile file;
        file.Create(pathToWString(path).c_str());
        file.Write(ecl);
        file.Close();
        //  ---  ---  ---

        m_view.SetSavePoint();
        IAttributeVector attrs;
        Dali::CEclExceptionVector errors;
        m_attribute->PreProcess(PREPROCESS_SAVE, NULL, attrs, errors);
        SendMessage(CWM_SUBMITDONE, Dali::WUActionCheck, (LPARAM)&errors);
        if (attrs.size())
        {
            if (!m_migrator)
                m_migrator = CreateIMigration(::AttachRepository(), false);
            m_migrator->Stop();
            for(IAttributeVector::const_iterator itr = attrs.begin(); itr != attrs.end(); ++itr)
                m_migrator->AddToRep(m_attribute->GetModule()->GetRootModule(), itr->get()->GetAsHistory(), (boost::_tformat(_T("Preprocessed (%1%) from %2%.")) % PREPROCESS_LABEL[PREPROCESS_SAVE] % m_attribute->GetQualifiedLabel()).str().c_str(), true);
            m_migrator->Start();
            SetTimer(0, 200);
        }
        return true;
    }
    return false;
}
Пример #3
0
CLIB_API const boost::filesystem::path & GetProgramPath(boost::filesystem::path & path)
{
    TCHAR programPath[_MAX_PATH];
    ::GetModuleFileName(0, programPath, _MAX_PATH);
    path = stringToPath(programPath);
    if(!g_appName.empty())
    {
        path = path.branch_path() / stringToPath(g_appName);
    }
    return path;
}
Пример #4
0
CLIB_API const boost::filesystem::path & GetEnvironmentFolder(boost::filesystem::path & path, const std::_tstring & user, const std::_tstring & environment)
{
    boost::filesystem::path userFolder;
    path = GetUserFolder(userFolder, user) / stringToPath(environment);
    boost::filesystem::create_directories(path);
    return path;
}
Пример #5
0
CLIB_API const boost::filesystem::path & GetUserFolder(boost::filesystem::path & path, const std::_tstring & user)
{
    boost::filesystem::path applicationFolder;
    path = GetApplicationFolder(applicationFolder) / stringToPath(user);
    boost::filesystem::create_directories(path);
    return path;
}
Пример #6
0
	void loadReference()
	{
		m_lang.clear();
		CString fileName = ReferenceFileName();
		//  Check if this user has customized the colors
		boost::filesystem::path binFolder;
		GetProgramFolder(binFolder);
		boost::filesystem::path file = binFolder / stringToPath(fileName.GetString());
		if (!clib::filesystem::exists(file))
		{
			ATLASSERT(!(_T("Unable to locate ") + fileName));
		}
		restore(m_lang, file.string().c_str());
		std::sort(m_lang.begin(), m_lang.end());
		int row = 0;
		for(CLanguageReferenceVector::iterator itr = m_lang.begin(); itr != m_lang.end(); ++itr)
		{
			std::_tstring name = itr->GetName();
			std::transform(name.begin(), name.end(), name.begin(), ::tolower);
			m_langNameIndex[name].m_cat = itr->GetCategoryID();
			m_langNameIndex[name].m_row = row;
			m_langCatNameIndex[itr->GetCategoryID()][name].m_cat = itr->GetCategoryID();
			m_langCatNameIndex[itr->GetCategoryID()][name].m_row = row;
			++row;
		}
	}
Пример #7
0
CLIB_API const boost::filesystem::path & GetCompanyFolder(boost::filesystem::path & path)
{
    boost::filesystem::path p;
    path = GetAppDataFolder(p) / stringToPath(COMPANY);
    boost::filesystem::create_directories(path);
    return path;
}
Пример #8
0
CLIB_API const boost::filesystem::path & GetMyDocumentsFolder(boost::filesystem::path & path)
{
    TCHAR appDataPath[_MAX_PATH];
    SHGetSpecialFolderPath(NULL, appDataPath, CSIDL_MYDOCUMENTS, true); 
    path = stringToPath(appDataPath);
    boost::filesystem::create_directories(path);
    return path;
}
Пример #9
0
CLIB_API const boost::filesystem::path & GetProgramFilesX86Folder(boost::filesystem::path & path)
{
    TCHAR appDataPath[_MAX_PATH];
    SHGetSpecialFolderPath(NULL, appDataPath, CSIDL_PROGRAM_FILESX86, true); 
    path = stringToPath(appDataPath);
    boost::filesystem::create_directories(path);
    return path;
}
Пример #10
0
	void RestoreDefaults()
	{
		boost::filesystem::path appFolder;
		GetApplicationFolder(appFolder);
		boost::filesystem::path file = appFolder / stringToPath(ColorFileName().GetString());
		if (clib::filesystem::exists(file))
			boost::filesystem::remove(file);
		loadMergedColor();
	}
Пример #11
0
void MouseMovementManager::setElements(const QList<qReal::Id> &elements)
{
	QMap<QString, PathVector> gestures;
	foreach (qReal::Id element, elements) {
		QString pathStr = mEditorManager->mouseGesture(element);
		if (!pathStr.isEmpty()) {
			PathVector path = stringToPath(pathStr);
			gestures.insert(element.toString(), path);
			mElements.push_back(element);
		}
	}
Пример #12
0
CLIB_API const boost::filesystem::path & GetApplicationFolder(boost::filesystem::path & path)
{
    CCmdLineParser parser(::GetCommandLine());
    if (parser.HasKey(_T("WF")))
    {
        std::_tstring workspace = parser.GetVal(_T("WF"));
        path = stringToPath(workspace);
    }
    else
    {
        boost::filesystem::path programPath;
        std::string leaf = pathToString(GetProgramPath(programPath).leaf());
        TCHAR szFileName[_MAX_FNAME];
        TCHAR szExt[_MAX_FNAME];
        _tsplitpath(CA2T(leaf.c_str()), NULL, NULL, szFileName, szExt);		
        boost::filesystem::path companyFolder;
        path = GetCompanyFolder(companyFolder) / stringToPath(szFileName);
    }
    boost::filesystem::create_directories(path);
    return path;
}
Пример #13
0
CLIB_API const boost::filesystem::path & GetConfigPath(const std::_tstring & environment, boost::filesystem::path & path)
{
    boost::filesystem::path applicationFolder;
    std::_tstring CfgFileName = environment;
    if (CfgFileName.find('.') == std::_tstring::npos)
    {
        CfgFileName += _T(".");
        CfgFileName += CFG;
    }
    path = GetApplicationFolder(applicationFolder) / stringToPath(CfgFileName);
    return path;
}
Пример #14
0
 void InitConfigPath(const std::_tstring & cfgName, const std::_tstring & ext)
 {
     clib::recursive_mutex::scoped_lock proc(m_mutex);
     m_CfgName = cfgName;
     ATLASSERT((cfgName.find('.') == std::_tstring::npos));
     ATLASSERT((ext.find('.') == std::_tstring::npos));
     std::_tstring cfgNameExt = cfgName;
     cfgNameExt += _T(".");
     cfgNameExt += ext;
     boost::filesystem::path appFolder;
     m_CfgPath = GetApplicationFolder(appFolder) / stringToPath(cfgNameExt);
     m_Cfg.SetFilename(pathToWString(m_CfgPath).c_str());
 }
Пример #15
0
CLIB_API const boost::filesystem::path & GetIniPath(boost::filesystem::path & path)
{
    boost::filesystem::path programPath;
    std::string leaf = pathToString(GetProgramPath(programPath).leaf());
    TCHAR szFileName[_MAX_FNAME];
    TCHAR szExt[_MAX_FNAME];
    _tsplitpath(CA2T(leaf.c_str()), NULL, NULL, szFileName, szExt);
    std::_tstring iniName = szFileName;
    iniName += _T(".");
    iniName += INI;
    boost::filesystem::path appFolder;
    path = GetApplicationFolder(appFolder) / stringToPath(iniName);
    return path;
}
Пример #16
0
CLIB_API const boost::filesystem::path & GetTempFolder(boost::filesystem::path & path)
{
    DWORD result = ::GetTempPath(0, _T(""));
    if (result == 0)
        return path;

    std::vector<TCHAR> tempPath(result);
    result = ::GetTempPath(static_cast<DWORD>(tempPath.size()), &tempPath[0]);
    if ((result == 0) || (result > tempPath.size()))
        return path;

    path = stringToPath(std::_tstring(tempPath.begin(), tempPath.begin() + static_cast<std::size_t>(result)));
    return path;
}
Пример #17
0
	void ExportLanguageReference()
	{
		boost::filesystem::path binFolder;
		GetProgramFolder(binFolder);
		boost::filesystem::path path = binFolder / stringToPath(LANGREFFILE_CSV);

		std::ofstream ofs(path.string());
		assert(ofs.good());

		for(CLanguageReferenceVector::iterator itr = m_lang.begin(); itr != m_lang.end(); ++itr)
		{
			std::_tstring line;
			ofs << CT2A(itr->ToCSV(line)) << std::endl;
		}
	}
Пример #18
0
	bool loadDefaultColor(CategoryLanguageColorMap & t)
	{
		t.clear();
		//  Check if this user has customized the colors
		boost::filesystem::path binFolder;
		GetProgramFolder(binFolder);
		boost::filesystem::path file = binFolder / stringToPath(ColorFileName().GetString());
		if (!clib::filesystem::exists(file))
		{
			return false;
		}
		restore(t, file.string().c_str());

		return true;
	}
Пример #19
0
	bool loadSamples()
	{
		if (m_sample.size() != 0)
			return true;

		m_sample.clear();
		boost::filesystem::path binFolder;
		GetProgramFolder(binFolder);
		boost::filesystem::path file = binFolder / stringToPath(LANGSYNTAXSAMPLES);
		if (!clib::filesystem::exists(file))
		{
			ATLASSERT(!(_T("Unable to locate language syntax sample file")));
		}
		restore(m_sample, file.string().c_str());
		return true;
	}
Пример #20
0
	bool loadMergedColorFile()
	{
		boost::filesystem::path appFolder;
		GetApplicationFolder(appFolder);
		boost::filesystem::path file = appFolder / stringToPath(ColorFileName(true).GetString());
		if (clib::filesystem::exists(file))
		{
			CategoryLanguageColorMap userColors;
			restore(userColors, file.string().c_str());
			for (CategoryLanguageColorMap::iterator itr = userColors.begin(); itr != userColors.end(); ++itr)
			{
				m_color[itr->first] = itr->second;
			}
			return true;
		}
		return false;
	}
Пример #21
0
void CDockableDataViews::SetTabEcl(const std::_tstring & localFile, int row, const CUniqueID & id)
{
    std::_tstring label = localFile;
    StringSourceMap::iterator itr = m_sourceTabs.find(localFile);
    if (itr == m_sourceTabs.end())
    {
        StlLinked<CLocalDataView> attributeDataView = new CLocalDataView();
        m_sourceTabs[localFile] = attributeDataView.get();
        attributeDataView->Create(NULL, localFile.c_str(), WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), &m_wndTab, 1);
        attributeDataView->SetFont(&afxGlobalData.fontRegular);
        boost::filesystem::path p = stringToPath(localFile);
        m_wndTab.AddTab(attributeDataView, pathToWString(p.filename()).c_str(), 0, FALSE);
        attributeDataView->SetOwner(m_owner);
        attributeDataView->SetSource(localFile);
    }
    m_sourceTabs[localFile]->SetBreakpointLocation(row, id);
}
Пример #22
0
	void Save()
	{
		boost::filesystem::path appFolder;
		GetApplicationFolder(appFolder);
		boost::filesystem::path file = appFolder / stringToPath(ColorFileName(true).GetString());

		CategoryLanguageColorMap defaultColors, diffColors;
		loadDefaultColor(defaultColors);
		bool diffFound = false;
		for (CategoryLanguageColorMap::iterator itr = m_color.begin(); itr != m_color.end(); ++itr)
		{
			if (defaultColors[itr->first] != itr->second)
			{
				diffColors[itr->first] = itr->second;
				diffColors[itr->first].Cleanup(&defaultColors[itr->first]);
				diffFound = true;
			}
		}

		if (diffFound)
		{
			save(diffColors, file.string().c_str());
		}
	}
Пример #23
0
int lookupMountEntry(const SBString *path, struct MountEntry **entry,
    SBFilePath *relPath)
{
  SBFilePath fPath;
  SBFilePath tmpPath;
  SBKey *keys, *bestKey=NULL;
  size_t numKeys=0, bestLength=0;

  if( path == NULL )
    return -1;

  sbFilePathCreate(&fPath);

  if( stringToPath(path, &fPath) != 0 )
  {
    sbFilePathDelete(&fPath);
    return -1;
  }

  if( sbAssocArrayKeys(&mountTable, &keys, &numKeys ) != 0 )
  {
    sbFilePathDelete(&fPath);
    return -1;
  }

  for(unsigned i=0; i < numKeys; i++, keys++)
  {
    size_t pathDepth, tmpDepth;
    SBString subPath, subTmp, keyStr;

    if( sbStringCreateN(&keyStr, keys->key, keys->keysize) < 0 )
      continue;

    sbFilePathCreate(&tmpPath);

    if( stringToPath(&keyStr, &tmpPath) != 0 )
    {
      sbFilePathDelete(&tmpPath);
      continue;
    }

    sbFilePathDepth(&fPath, &pathDepth);
    sbFilePathDepth(&tmpPath, &tmpDepth);

    if( pathDepth < tmpDepth )
    {
      sbFilePathDelete(&tmpPath);
      continue;
    }
    else if( tmpDepth == 0 )
    {
      SBString rootPath;

      if( sbStringCreate(&rootPath, "/") < 0 )
      {
        sbFilePathDelete(&fPath);
        sbFilePathDelete(&tmpPath);
        return -1;
      }

      if( entry )
      {
        if( sbAssocArrayLookup(&mountTable, rootPath.data, sbStringLength(&rootPath), (void **)entry, NULL) != 0 )
        {
          sbFilePathDelete(&fPath);
          sbFilePathDelete(&tmpPath);
          sbStringDelete(&rootPath);
          return -1;
        }
      }

      if( relPath )
        stringToPath(path, relPath);

      sbStringDelete(&rootPath);
      sbFilePathDelete(&tmpPath);
      sbFilePathDelete(&fPath);
      return 0;
    }

    for(unsigned j=0; j < tmpDepth; j++)
    {
      if( sbFilePathAtLevel(&fPath, j, &subPath) != 0 )
        break;
      if( sbFilePathAtLevel(&tmpPath, j, &subTmp) != 0 )
        break;
      if( sbStringCompare(&subPath, &subTmp) != SBStringCompareEqual )
        break;

      if( j + 1 > bestLength )
      {
        bestLength = j+1;
        bestKey = keys;
      }
    }

    sbFilePathDelete(&tmpPath);
  }

  if( !bestKey )
  {
    print("No best key.\n");
    return -1;
  }

  if( entry )
  {
    if( sbAssocArrayLookup(&mountTable, bestKey->key, bestKey->keysize, (void **)entry, NULL) != 0 )
    {
      sbFilePathDelete(&fPath);
      return -1;
    }
  }

  if( relPath && sbArraySlice(&fPath, bestLength, -1, relPath) != 0 )
  {
    sbFilePathDelete(&fPath);
    return -1;
  }

  sbFilePathDelete(&fPath);
  return 0;
}