Пример #1
0
void Project::GetFiles(std::vector<wxFileName> &files, bool absPath)
{
    if (absPath) {
        DirSaver ds;
        ::wxSetWorkingDirectory(m_fileName.GetPath());

        GetFiles(m_doc.GetRoot(), files, true);
    } else {
        GetFiles(m_doc.GetRoot(), files, false);
    }
}
Пример #2
0
inline HRESULT __stdcall ISimpleDropTarget::DragEnter(IDataObject * pDataObject, DWORD grfKeyState, POINTL ptl, DWORD * pdwEffect)
{
	POINT pt;
	pt.x = ptl.x;
	pt.y = ptl.y;
	if (m_pdth && PrevFancyRenderer) {              
		m_pdth->DragEnter(m_hwnd, pDataObject, &pt, *pdwEffect);
	}
	m_DataObject = pDataObject;     
	dragInAction = true;
	m_RightData = QueryDataObject(pDataObject);

	bool canDrop = m_RightData && AllowDrop(ptl);
	if (canDrop)
	{
		SetFocus(m_hwnd);
		auto files = GetFiles(pDataObject);
		*pdwEffect = OnDragEnter(files, grfKeyState, ptl);
	}
	else
	{
		*pdwEffect = DROPEFFECT_NONE;
	}
	return S_OK;

}
Пример #3
0
NS_IMETHODIMP
DataTransfer::GetFiles(nsIDOMFileList** aFileList)
{
  ErrorResult rv;
  NS_IF_ADDREF(*aFileList = GetFiles(rv));
  return rv.ErrorCode();
}
Пример #4
0
void Project::GetFiles(wxXmlNode *parent, std::vector<wxFileName>& files, std::vector<wxFileName>& absFiles)
{
    if ( !parent ) {
        return;
    }

    wxXmlNode *child = parent->GetChildren();
    while (child) {
        if (child->GetName() == wxT("File")) {
            wxString fileName = child->GetPropVal(wxT("Name"), wxEmptyString);
            wxFileName tmp(fileName);

            // append the file as it appears
            files.push_back(tmp);

            // convert to absolute path
            tmp.MakeAbsolute();
            absFiles.push_back(tmp);

        } else if (child->GetChildren()) {// we could also add a check for VirtualDirectory only
            GetFiles(child, files, absFiles);
        }
        child = child->GetNext();
    }
}
void DirectoryLexicalAnalyzer::Initialize()
{
    std::vector <std::string> fileNames = GetFiles();
    for (auto fileNameIter = fileNames.begin(); fileNameIter != fileNames.end(); ++fileNameIter)
    {
        std::fstream file;
        file.open(*fileNameIter, std::ios_base::in);
        while (!file.eof())
        {
            std::string word;
            file >> word;

            if (word.length() > 0)
            {
                word = GetWordWithoutSurroundingPunctuation(word, ",:;![]{}()'\"");

                if (word.length() > 0)
                {
                    // we lower case the first letter, unless there are capitals inside the word
                    // in which case we assume that it's some kind of abbreviation
                    if (std::none_of(word.begin() + 1, word.end(), ::isupper))
                        word[0] = ::tolower(word[0]);

                    m_WordCount++;
                    m_Frequency[word]++;
                    m_LongestWordLength = max(word.length(), m_LongestWordLength);
                }
            }
        }
        file.close();
    }
    m_IsInitialized = true;
}
Пример #6
0
	bool Folder::Delete(bool recursively)const
	{
		if (!Exists()) return false;
		if (recursively)
		{
			std::list<Folder> folders;
			GetFolders(folders);
			for (auto iter = folders.begin(); iter != folders.end(); iter++)
			{
				if (!(*iter).Delete(true))
				{
					return false;
				}
			}

			std::list<File> files;
			GetFiles(files);
			for (auto iter = files.begin(); iter != files.end(); iter++)
			{
				if (!(*iter).Delete())
				{
					return false;
				}
			}

			return Delete(false);
		}
		return RemoveDirectory(filePath_.GetFullPath().Buffer()) != 0;
	}
Пример #7
0
// compiles all files
bool opDriver::NormalMode(const opParameters& p) {
    // verify the output directory...
    path dirpath = p.GeneratedDirectory.GetString();

    if (!exists(dirpath)) create_directories(dirpath);

    opSet<path> files = GetFiles();

    // if there are no files to compile, return false
    if (files.size() == 0) {
        if (!p.Silent) Log("Error: No files to compile!");

        return false;
    }

    // compile all files
    bool bResult = true;

    typedef opSet<path>::const_iterator fileit;

    if (p.Verbose)  // spacing in verbose mode
        Log(' ');

    for (fileit it = files.begin(); it != files.end(); ++it) {
        bResult = NormalModeFile(p, *it) ? bResult : false;
    }

    // If we had errors, print out the number of errors.
    if (NumErrors > 0) {
        Log("");
        string errorstring = (NumErrors == 1) ? " error" : " errors";
        Log("opC++ - " + opString(NumErrors) + errorstring);
        Log("");
    }

    if (!p.Silent && files.size() > 1) {
        if (p.Verbose) {
            Log(' ');

            if (bResult) {
                Log("opC++ - 0 errors");
                Log("");
                Log("--------------------------------");
                Log("All Files Compiled Successfully!");
                Log("--------------------------------");
            } else {
                Log("-------------------------------------");
                Log("Some File(s) Compiled Unsuccessfully!");
                Log("-------------------------------------");
            }

            Log(' ');
        }
    }

    return bResult;
}
Пример #8
0
	std::vector<std::string> FileSystem::GetFilesWithRecursion(const std::string & directory)
	{
		std::vector<std::string> list = GetFiles(directory);
		for (std::string subdir : GetDirectories(directory)) {
			auto files = GetFilesWithRecursion(subdir);
			list.insert(list.end(), files.begin(), files.end());
		}
		return list;
	}
Пример #9
0
void PHPFolder::RemoveFilesRecursively(const wxString& projectPath, bool notify)
{
    wxArrayString files;
    GetFiles(files, projectPath);
    if(notify) {
        DoNotifyFilesRemoved(files);
    }
    m_children.clear();
    m_files.clear();
}
Пример #10
0
void Project::GetFiles(wxStringSet_t& files)
{
    DirSaver ds;
    FileNameVector_t v;
    ::wxSetWorkingDirectory(m_fileName.GetPath());
    GetFiles(m_doc.GetRoot(), v, true);
    for(size_t i=0; i<v.size(); i++) {
        files.insert(v.at(i).GetFullPath());
    }
}
Пример #11
0
void ListGenerator::CreateList(u32 Flow, u32 Device, const string& Path, const vector<string>& FileTypes, 
								const string& DBName, bool UpdateCache)
{
	if(!DBName.empty())
	{
		if(UpdateCache)
			fsop_deleteFile(DBName.c_str());
		else
		{
			CCache(*this, DBName, LOAD);
			if(!this->empty())
				return;
			fsop_deleteFile(DBName.c_str());
		}
	}
	//if(Flow != COVERFLOW_PLUGIN)
		OpenConfigs();
	if(Flow == COVERFLOW_WII)
	{
		if(DeviceHandle.GetFSType(Device) == PART_FS_WBFS)
			Create_Wii_WBFS_List(DeviceHandle.GetWbfsHandle(Device));
		else
			GetFiles(Path.c_str(), FileTypes, Create_Wii_EXT_List, false);
	}
	else if(Flow == COVERFLOW_CHANNEL)
	{
		ChannelHandle.Init(gameTDB_Language);
		Create_Channel_List();
	}
	else if(DeviceHandle.GetFSType(Device) != PART_FS_WBFS)
	{
		if(Flow == COVERFLOW_GAMECUBE)
			GetFiles(Path.c_str(), FileTypes, Create_GC_List, true);//the only one that looks for a folder (/root)
		else if(Flow == COVERFLOW_PLUGIN)
			GetFiles(Path.c_str(), FileTypes, Create_Plugin_List, false, 30);//wow 30 subfolders! really?
		else if(Flow == COVERFLOW_HOMEBREW)
			GetFiles(Path.c_str(), FileTypes, Create_Homebrew_List, false);
	}
	CloseConfigs();
	if(!this->empty() && !DBName.empty()) /* Write a new Cache */
		CCache(*this, DBName, SAVE);
}
Пример #12
0
void Project::GetFiles(wxStringSet_t& files, const wxString& relativePath)
{
    DirSaver ds;
    FileNameVector_t v;
    ::wxSetWorkingDirectory(relativePath);
    GetFiles(m_doc.GetRoot(), v, false);
    for(size_t i=0; i<v.size(); i++) {
        v.at(i).MakeRelativeTo(relativePath);
        files.insert(v.at(i).GetFullPath());
    }
}
Пример #13
0
void Musicplayer::Init(Config &cfg, const string& musicDir, const string& themeMusicDir) 
{
	Cleanup();
	FadeRate = cfg.getInt("GENERAL", "music_fade_rate", 8);
	Volume = cfg.getInt("GENERAL", "sound_volume_music", 255);

	SetVolume(0);
	MusicFile.SetVoice(0);

	vector<string> Types = stringToVector(".mp3|.ogg", '|');
	GetFiles(musicDir.c_str(), Types, FileNameAdder, false, MUSIC_DEPTH);
	GetFiles(themeMusicDir.c_str(), Types, FileNameAdder, false, MUSIC_DEPTH);
	if(cfg.getBool("GENERAL", "randomize_music", true) && FileNames.size() > 0)
	{
		srand(unsigned(time(NULL)));
		random_shuffle(FileNames.begin(), FileNames.end());
	}
	OneSong = (FileNames.size() == 1);
	CurrentFileName = FileNames.begin();
}
Пример #14
0
void Gather(const char* archivePathName, const char* outputPathName)
{
	Framework::CStdStream outputStream(outputPathName, "wb");
	CBasicBlock::SetAotBlockOutputStream(&outputStream);

	{
		Framework::CThreadPool threadPool(std::thread::hardware_concurrency());

		filesystem::path archivePath = filesystem::path(archivePathName);
		auto archive = std::unique_ptr<CPsfArchive>(CPsfArchive::CreateFromPath(archivePath));

		for(const auto& fileInfo : archive->GetFiles())
		{
			filesystem::path archiveItemPath = fileInfo.name;
			filesystem::path archiveItemExtension = archiveItemPath.extension();
			if(CPlaylist::IsLoadableExtension(archiveItemExtension.string().c_str() + 1))
			{
				threadPool.Enqueue(
					[=] ()
					{
						printf("Processing %s...\r\n", archiveItemPath.string().c_str());

						CPsfVm virtualMachine;

						CPsfLoader::LoadPsf(virtualMachine, archiveItemPath.wstring(), archivePath);
						int currentTime = 0;
						virtualMachine.OnNewFrame.connect(
							[&currentTime] ()
							{
								currentTime += 16;
							});

						virtualMachine.Resume();

#ifdef _DEBUG
						static const unsigned int executionTime = 1;
#else
						static const unsigned int executionTime = 10;
#endif
						while(currentTime <= (executionTime * 60 * 1000))
						{
							std::this_thread::sleep_for(std::chrono::milliseconds(10));
						}

						virtualMachine.Pause();
					}
				);
			}
		}
	}

	CBasicBlock::SetAotBlockOutputStream(nullptr);
}
Пример #15
0
NS_IMETHODIMP
nsEmbedFilePicker::GetDomfiles(nsISimpleEnumerator * *aDomfiles)
{
  nsCOMPtr<nsISimpleEnumerator> iter;
  nsresult rv = GetFiles(getter_AddRefs(iter));
  NS_ENSURE_SUCCESS(rv, rv);

  nsRefPtr<nsBaseFilePickerEnumerator> retIter =
    new nsBaseFilePickerEnumerator(iter, mWin);

  retIter.forget(aDomfiles);
  return NS_OK;
}
Пример #16
0
void PopulateList()
{
	char label[MAX_PATHNAME_LEN];
	char fileName[MAX_PATHNAME_LEN];
	int numItems = 1; 
	
	ClearListCtrl (Main_pnl_handle, ERG_panel_loaded_mask_list);
	InsertListItem (Main_pnl_handle, ERG_panel_loaded_mask_list, -1, "flat", 0);
	
	SplitPath (mask_path, NULL, NULL, fileName);
	Fmt (label, "%s<%s%s%s", "Project Directory (", fileName, ")");
	GetFiles(mask_path, &numItems, numItems-1);
}
Пример #17
0
void Ide::IdePaste(String& data)
{
	data.Clear();
	if(AcceptFiles(Clipboard())) {
		Vector<String> s = GetFiles(Clipboard());
		for(int i = 0; i < s.GetCount(); i++)
			if(FileExists(s[i]) && IsTextFile(s[i], 10000)) {
				int64 len = GetFileLength(s[i]);
				if(len > 5000000 || data.GetLength() + len < 5000000)
					data.Cat(LoadFile(s[i]));
			}
	}
}
Пример #18
0
wxString Project::GetFiles(bool absPath)
{
    std::vector<wxFileName> files;
    GetFiles(files,absPath);

    wxString temp;
    for (size_t i = 0; i < files.size(); i++)
        temp << wxT("\"") << files.at(i).GetFullPath() << wxT("\" ");

    if(temp.IsEmpty() == false)
        temp.RemoveLast();

    return temp;
}
Пример #19
0
void nglDataFilesObject::SetDragItemFlavorData(DragRef dragRef, DragItemRef& itemRef, FlavorType flavorType)
{
  OSErr err = noErr;
  nglString file;
  std::list<DragItemRef>::iterator iRef = mItemRefs.begin();
  for (std::list<nglString>::const_iterator i = GetFiles().begin(); i != GetFiles().end() && iRef != mItemRefs.end(); ++i, ++iRef)
  {
    if (itemRef == *iRef)
    {
      HFSFlavor hfsInfo;
      FSRef fileRef;
      int32 start = 0;
      int32 len = 1023;
      char str[1024];
      memset(str, 0, 1024);
      i->Export(start, str, len, eUTF8);
      err = FSPathMakeRef((const UInt8*)str, &fileRef, NULL);
      NGL_ASSERT(!err);
      
      FSCatalogInfo catInfo;
      err = FSGetCatalogInfo(&fileRef, kFSCatInfoFinderInfo, &catInfo, NULL, &(hfsInfo.fileSpec), NULL);
      NGL_ASSERT(!err);
      
      FileInfo* finfo = (FileInfo*) &catInfo.finderInfo;
      hfsInfo.fdFlags = finfo->finderFlags;
      hfsInfo.fileType = finfo->fileType;
      hfsInfo.fileCreator = finfo->fileCreator;
        
      err = ::SetDragItemFlavorData(dragRef, itemRef, kDragFlavorTypeHFS, &hfsInfo, sizeof (hfsInfo), 0);
      NGL_ASSERT(!err);
        
      //NGL_OUT("Adding file to drag data, itemRef is %d: %s\n", itemRef, (*i).GetChars());
      return;
    }
  }
}
Пример #20
0
vector<pair<string,string>> GetFiles(const path& Path,bool Recurse,const set<string>& FileMasks){
    vector<pair<string,string>> Files;
    if(exists(Path)&&is_directory(Path)){
        for(directory_iterator Iter(Path);Iter!=directory_iterator();Iter++){
            directory_entry Entry=*Iter;
            const path& P=Entry.path();
            if(is_directory(P)){
                if(Recurse)Files+=GetFiles(P,true,FileMasks);
            }else if(is_regular_file(P)){
                string Extension=P.extension().string();
                if(FileMasks.size()==0u||FileMasks.count(Extension)){
                    Files.push_back(pair<string,string>(P.string(),Extension));
                }
            }
        }
    }
    return Files;
}
Пример #21
0
void OnlineAbsentCountriesFetcher::GetAbsentCountries(vector<string> & countries)
{
  // Check whether a request was scheduled to be run on the thread.
  if (!m_fetcherThread)
    return;
  m_fetcherThread->Join();
  for (auto const & point : m_fetcherThread->GetRoutineAs<OnlineCrossFetcher>()->GetMwmPoints())
  {
    string name = m_countryFileFn(point);
    auto localFile = m_countryLocalFileFn(name);
    if (localFile && HasOptions(localFile->GetFiles(), MapOptions::MapWithCarRouting))
      continue;

    LOG(LINFO, ("Needs: ", name));
    countries.emplace_back(move(name));
  }
  m_fetcherThread.reset();
}
Пример #22
0
void CMenu::_refreshLangSettings(void)
{
	languages_available.clear();
	/* Get right Positions first */
	languages_available.push_back("Default");
	GetFiles(m_languagesDir.c_str(), stringToVector(".ini", '|'), AddLanguage, false, 0);
	std::sort(languages_available.begin(), languages_available.end());

	for(u32 i = 0; i < languages_available.size(); ++i)
	{
		if(m_curLanguage == languages_available[i])
		{
			available_pos = i;
			break;
		}
	}
	_showLangSettings();
}
Пример #23
0
void SearchThread::DoSearchFiles(ThreadRequest *req)
{
    SearchData *data = static_cast<SearchData*>(req);

    // Get all files
    if ( data->GetRootDirs().IsEmpty() )
        return;

    if ( data->GetFindString().IsEmpty() )
        return;

    StopSearch(false);
    wxArrayString fileList;
    GetFiles(data, fileList);

    wxStopWatch sw;

    // Send startup message to main thread
    if ( m_notifiedWindow || data->GetOwner() ) {
        wxCommandEvent event(wxEVT_SEARCH_THREAD_SEARCHSTARTED, GetId());
        event.SetClientData(new SearchData(*data));
        //set the rquested output tab
        event.SetInt(data->UseNewTab() ? 1 : 0);
        if (data->GetOwner()) {
            ::wxPostEvent(data->GetOwner(), event);
        } else {
            // since we are in if ( m_notifiedWindow || data->GetOwner() ) block...
            ::wxPostEvent(m_notifiedWindow, event);
        }
    }

    for (size_t i=0; i<fileList.Count(); i++) {
        m_summary.SetNumFileScanned((int)i+1);

        // give user chance to cancel the search ...
        if ( TestStopSearch() ) {
            // Send cancel event
            SendEvent(wxEVT_SEARCH_THREAD_SEARCHCANCELED, data->GetOwner());
            StopSearch(false);
            break;
        }
        DoSearchFile(fileList.Item(i), data);
    }
}
Пример #24
0
void FbViewThread::OpenBook()
{
	int id = m_view.GetCode();
	m_book = FbCollection::GetBookData(id);
	if (!m_book) {
		SendHTML(ID_BOOK_PREVIEW);
		return;
	}

	if (IsClosed()) return;

	wxString html = FbCollection::GetBookHTML(m_ctx, m_book, id);
	if (!html.IsEmpty()) {
		SendHTML(ID_BOOK_PREVIEW, html);
		return;
	}

	if (IsClosed()) return;

	FbViewData * info = new FbViewData(id);
	{
		wxString filetype = m_book.GetValue(BF_TYPE);
		FbCommonDatabase database;
		database.JoinThread(this);
		info->SetText(FbViewData::DSCR, GetDescr(database));
		info->SetText(FbViewData::FILE, GetFiles(database));
		info->SetText(FbViewData::SEQN, GetSeqns(database));
		info->SetText(FbViewData::ICON, FbCollection::GetIcon(filetype));
		SendHTML(*info);
	}

	if (IsClosed()) { delete info; return; }

	FbFileReader file(id, true);
	if (file.IsOk()) {
		wxInputStream & in = file.GetStream();
		if (file.GetFileType() == wxT("epub")) {
			FbPreviewReaderEPUB(*this, *info).Preview(in);
		} else {
			FbPreviewReader(*this, *info).Parse(in);
		}
	}
	FbCollection::AddInfo(info);
}
Пример #25
0
void Project::GetFiles(wxXmlNode *parent, std::vector<wxFileName> &files, bool absPath)
{
    if ( !parent ) {
        return;
    }

    wxXmlNode *child = parent->GetChildren();
    while (child) {
        if (child->GetName() == wxT("File")) {
            wxString fileName = child->GetPropVal(wxT("Name"), wxEmptyString);
            wxFileName tmp(fileName);
            if (absPath) {
                tmp.MakeAbsolute();
            }
            files.push_back(tmp);
        } else if (child->GetChildren()) {// we could also add a check for VirtualDirectory only
            GetFiles(child, files, absPath);
        }
        child = child->GetNext();
    }
}
Пример #26
0
bool Project::IsFileExist(const wxString &fileName)
{
    //find the file under this node
    // Convert the file path to be relative to
    // the project path
    DirSaver ds;

    ::wxSetWorkingDirectory(m_fileName.GetPath());
    wxFileName tmp(fileName);
    tmp.MakeRelativeTo(m_fileName.GetPath());

    std::vector<wxFileName> files;
    GetFiles(files);

    for (size_t i=0; i<files.size(); i++) {
        if (files.at(i).GetFullPath().CmpNoCase(tmp.GetFullPath(wxPATH_UNIX)) == 0) {
            return true;
        }
    }
    return false;
}
Пример #27
0
void GetFiles(const char *Path, const vector<string>& FileTypes, 
				FileAdder AddFile, bool CompareFolders, u32 max_depth, u32 depth)
{
	vector<string> SubPaths;

	pdir = opendir(Path);
	if(pdir == NULL)
		return;
	while((pent = readdir(pdir)) != NULL)
	{
		if(pent->d_name[0] == '.')
			continue;
		FullPathChar = fmt("%s/%s", Path, pent->d_name);
		if(pent->d_type == DT_DIR)
		{
			if(CompareFolders && IsFileSupported(pent->d_name, FileTypes))//if root folder for extracted gc games
			{
				AddFile(FullPathChar);
				continue;
			}
			else if(depth < max_depth) //thanks libntfs (fail opendir) and thanks seekdir (slowass speed)
				SubPaths.push_back(FullPathChar);
		}
		else if(pent->d_type == DT_REG)
		{
			NewFileName = strrchr(pent->d_name, '.');//the extension
			if(NewFileName == NULL) NewFileName = pent->d_name;
			if(IsFileSupported(NewFileName, FileTypes))
			{
				AddFile(FullPathChar);
				continue;
			}
		}
	}
	closedir(pdir);
	for(vector<string>::const_iterator p = SubPaths.begin(); p != SubPaths.end(); ++p)
		GetFiles(p->c_str(), FileTypes, AddFile, CompareFolders, max_depth, depth + 1);
	SubPaths.clear();
}
Пример #28
0
already_AddRefed<Promise>
DataTransfer::GetFilesAndDirectories(ErrorResult& aRv)
{
  nsCOMPtr<nsINode> parentNode = do_QueryInterface(mParent);
  if (!parentNode) {
    aRv.Throw(NS_ERROR_FAILURE);
    return nullptr;
  }

  nsCOMPtr<nsIGlobalObject> global = parentNode->OwnerDoc()->GetScopeObject();
  MOZ_ASSERT(global);
  if (!global) {
    aRv.Throw(NS_ERROR_FAILURE);
    return nullptr;
  }

  RefPtr<Promise> p = Promise::Create(global, aRv);
  if (aRv.Failed()) {
    return nullptr;
  }

  if (!mFileList) {
    GetFiles(aRv);
    if (NS_WARN_IF(aRv.Failed())) {
      return nullptr;
    }
  }

  Sequence<RefPtr<File>> filesSeq;
  mFileList->ToSequence(filesSeq, aRv);
  if (NS_WARN_IF(aRv.Failed())) {
    return nullptr;
  }

  p->MaybeResolve(filesSeq);

  return p.forget();
}
Пример #29
0
CPLErr BatchTxt(const char * idir, const char * odir, Option opt)
{
	char ** files = GetFiles(idir);
	ON_SCOPE_EXIT([&]{CSLDestroy(files); });

	char ** shps = GetSources(odir, files);
	ON_SCOPE_EXIT([&]{CSLDestroy(shps); });

	CPLErr err = CE_None;

	for (int i = 0; i < CSLCount(files); i++)
	{
		err = Txt2Any(files[i], shps[i], opt);

		if (err != CE_None)
		{
			break;
		}
	}

	printf("OK");

	return err;
}
Пример #30
0
inline HRESULT __stdcall ISimpleDropTarget::Drop(IDataObject * pDataObject, DWORD grfKeyState, POINTL ptl, DWORD * pdwEffect)
{
	POINT pt;
	pt.x = ptl.x;
	pt.y = ptl.y;
	if (m_pdth) {
		m_pdth->Drop(pDataObject, &pt, *pdwEffect);
	}

	m_DataObject = NULL; 
	dragInAction = false;
	bool canDrop = m_RightData && AllowDrop(ptl);
	if (canDrop)
	{
		auto files = GetFiles(pDataObject);
		OnDragDrop(files, grfKeyState, ptl);
	}
	else
	{
		*pdwEffect = DROPEFFECT_NONE;
	}
	return S_OK;

}