Exemple #1
0
side::side(string p, size_t x, size_t y) 
: indexFile(0), upIndexFile(0), indexRow(0), path(std::move(p)), posX(x), posY(y), isActive(true)
{
	if (!fillFiles())
		throw string("Can't read the directory: " + path);
	
	loadFilesPath();
}
Exemple #2
0
bool side::enter()
{
	if (filesPath.size() < 2 && !(_stricmp(files[indexFile].name, "..")))
		return false;
	else if (!(_stricmp(files[indexFile].name, "..")))  //..
	{
		string tName(filesPath.back());
		filesPath.pop_back();
		makePath();
		if (!fillFiles())
			throw string("Can't read the directory: " + path);
		indexFile = getIndexByNameInCurrent(tName);
		if (indexFile >= side::countFiles)  // не вміщається в першу (значить хз :) десь посерединці поставимо :))
		{
			indexRow = 10;
			upIndexFile = indexFile - 10;
		}
		else // ваміщається в перший комлект
		{
			upIndexFile = 0;
			indexRow = indexFile;
		}
		show();
		writePath();
		return true;
	}
	else if ((_stricmp(files[indexFile].name, "..")) && !(files[indexFile].attrib & _A_SUBDIR))
		return false;
	else   // not .. but folder
	{
		filesPath.emplace_back(files[indexFile].name);
		makePath();
		if (!fillFiles())
			throw string("Can't read the directory: " + path);
		clearIndex();
		show();
		writePath();
		return true;
	}
	
}
Exemple #3
0
void side::makeDir(string name)
{
	_mkdir((path + name).c_str());
	fillFiles();
	indexFile = getIndexByNameInCurrent(name);
	if (indexFile >= side::countFiles)  // не вміщається в першу (значить хз :) десь посерединці поставимо :))
	{
		indexRow = 10;
		upIndexFile = indexFile - 10;
	}
	else // ваміщається в перший комлект
	{
		upIndexFile = 0;
		indexRow = indexFile;
	}
	show();

}
void ListFileProvider::fillFiles( const CString& path )
{
	CFileFind finder;
	
	CString p = path + "\\*.*";
	if ( !finder.FindFile( p ) )
		return;

	// hack to avoid reading 
	std::string legacyThumbnailPostfix = ".thumbnail.bmp";
	int legacyThumbSize = (int)legacyThumbnailPostfix.length();
	int thumbSize = (int)thumbnailPostfix_.length();

	bool ignoreFiles = false;
	if ( !includeFolders_.empty()
		&& !StringUtils::matchSpec( (LPCTSTR)path, includeFolders_ ) )
		ignoreFiles = true;

	BOOL notEOF = TRUE;
	while( notEOF && getThreadWorking() )
	{
		notEOF = finder.FindNextFile();
		if ( !finder.IsDirectory() )
		{
			if ( !ignoreFiles )
			{
				std::string fname( (LPCTSTR)finder.GetFileName() );
				if ( StringUtils::matchExtension( fname, extensions_ )
					&& ( (int)fname.length() <= thumbSize
						|| fname.substr( fname.length() - thumbSize ) != thumbnailPostfix_ )
					&& ( (int)fname.length() <= legacyThumbSize
						|| fname.substr( fname.length() - legacyThumbSize ) != legacyThumbnailPostfix )
					)
				{
					ListItemPtr item = new ListItem();
					item->fileName = (LPCTSTR)finder.GetFilePath();
					item->dissolved = BWResource::dissolveFilename( item->fileName );
					item->title = (LPCTSTR)finder.GetFileName();
					threadMutex_.grab();
					if ( (threadItems_.size() % VECTOR_BLOCK_SIZE) == 0 )
						threadItems_.reserve( threadItems_.size() + VECTOR_BLOCK_SIZE );
					threadItems_.push_back( item );
					threadMutex_.give();
				}
			}
		}
		else if ( !finder.IsDots()
			&& !( flags_ & LISTFILEPROV_DONTRECURSE )
			&& ( excludeFolders_.empty()
				|| !StringUtils::matchSpec( (LPCTSTR)finder.GetFilePath(), excludeFolders_ ) )
			)
		{
			fillFiles( finder.GetFilePath() );
		}

		if ( threadYieldMsec_ > 0 )
		{
			if ( ( clock() - yieldClock_ ) * 1000 / CLOCKS_PER_SEC > threadYieldMsec_ )
			{
				Sleep( 50 ); // yield
				yieldClock_ = clock();
			}
		}

		if ( ( clock() - flushClock_ ) * 1000 / CLOCKS_PER_SEC >= threadFlushMsec_  )
		{
			flushThreadBuf();
			flushClock_ = clock();
		}
	}
}
void LoadFileDialog::Impl::deleteFile()
{
  vfs::Path path4delete( saveItemText );
  vfs::NFile::remove( directory/path4delete );
  fillFiles();
}