Exemplo n.º 1
0
fs::path uniquify(const fs::path &dest)
{
    std::string ext = dest.extension();
    std::string fname = dest.stem();
    fs::path parent = dest.parent_path();

    unsigned number = 1;
    std::string newfname;
    fs::path newdest;

    boost::smatch match;
    if(boost::regex_search(fname, match, uregex)) {
        // Matches are indexes into fname, so don't change it while reading values
        newfname = match[1];
        number = boost::lexical_cast<short>(match[2]);
        fname = newfname;
    }

    do { 
        newfname = fname + "(" + boost::lexical_cast<std::string>(++number) + ")" + ext;
        newdest = parent / newfname;
    } while(fs::exists(newdest));

    return newdest;
}
Exemplo n.º 2
0
void ScintillaEditor::enumerateColorSchemesInPath(ScintillaEditor::colorscheme_set_t &result_set, const fs::path path)
{
	const fs::path color_schemes = path / "color-schemes" / "editor";

	fs::directory_iterator end_iter;

	if (fs::exists(color_schemes) && fs::is_directory(color_schemes)) {
		for (fs::directory_iterator dir_iter(color_schemes); dir_iter != end_iter; ++dir_iter) {
			if (!fs::is_regular_file(dir_iter->status())) {
				continue;
			}

			const fs::path path = (*dir_iter).path();
			if (!(path.extension() == ".json")) {
				continue;
			}

			EditorColorScheme *colorScheme = new EditorColorScheme(path);
			if (colorScheme->valid()) {
				result_set.insert(colorscheme_set_t::value_type(colorScheme->index(), shared_ptr<EditorColorScheme>(colorScheme)));
			} else {
				delete colorScheme;
			}
		}
	}
}
Exemplo n.º 3
0
void DXTencoderApp::loadMovieFile( const fs::path &moviePath )
{
    try {
        mMovie = qtime::MovieSurface::create( moviePath );
        
        console() << "Dimensions:" << mMovie->getWidth() << " x " << mMovie->getHeight() << std::endl;
        console() << "Duration:  " << mMovie->getDuration() << " seconds" << std::endl;
        console() << "Frames:    " << mMovie->getNumFrames() << std::endl;
        console() << "Framerate: " << mMovie->getFramerate() << std::endl;
        console() << "Has audio: " << mMovie->hasAudio() << " Has visuals: " << mMovie->hasVisuals() << std::endl;

        mMovie->setLoop( false );
        mMovie->seekToStart();
        //mMovie->play();
        isStarted = true;
        currentFrame = 0;

        
        std::string basePath = moviePath.parent_path().string();
        string newFilename =   moviePath.filename().string();
        strReplace(newFilename, moviePath.extension().string(), ".dxt5");
                                                  
        mDxtCreator.open(basePath + "/" + newFilename);

    }
    catch( ci::Exception &exc ) {
        console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
    }
    
    
    
}
Exemplo n.º 4
0
	bool FileFinder::fileExtMatch(const fs::path test)
	{
		if (m_ext == "*")
			return(true);
		else if (m_ext == test.extension())
			return(true);
		else
			return(false);
	}
Exemplo n.º 5
0
// Functor operator, gets invoked on directory traversal
void ModuleLoader::processModuleFile(const fs::path& file)
{
	// Check for the correct extension of the visited file
	if (string::to_lower_copy(file.extension().string()) != MODULE_FILE_EXTENSION) return;

	std::string fullName = file.string();
	rConsole() << "ModuleLoader: Loading module '" << fullName << "'" << std::endl;

	// Create the encapsulator class
	DynamicLibraryPtr library = std::make_shared<DynamicLibrary>(fullName);

	// greebo: Try to find our entry point and invoke it and add the library to the list
	// on success. If the load fails, the shared pointer won't be added and
	// self-destructs at the end of this scope.
	if (library->failed())
	{
		rError() << "WARNING: Failed to load module " << library->getName() << ":" << std::endl;

#ifdef __linux__
		rConsoleError() << dlerror() << std::endl;
#endif
		return;
	}

	// Library was successfully loaded, lookup the symbol
	DynamicLibrary::FunctionPointer funcPtr(
		library->findSymbol(SYMBOL_REGISTER_MODULE)
	);

	if (funcPtr == nullptr)
	{
		// Symbol lookup error
		rError() << "WARNING: Could not find symbol " << SYMBOL_REGISTER_MODULE
			<< " in module " << library->getName() << ":" << std::endl;
		return;
	}

	// Brute-force conversion of the pointer to the desired type
	RegisterModulesFunc regFunc = reinterpret_cast<RegisterModulesFunc>(funcPtr);

	try
	{
		// Call the symbol and pass a reference to the ModuleRegistry
		// This method might throw a ModuleCompatibilityException in its
		// module::performDefaultInitialisation() routine.
		regFunc(ModuleRegistry::Instance());

		// Add the library to the static list (for later reference)
		_dynamicLibraryList.push_back(library);
	}
	catch (module::ModuleCompatibilityException&)
	{
		// Report this error and don't add the module to the _dynamicLibraryList
		rError() << "Compatibility mismatch loading library " << library->getName() << std::endl;
	}
}
Exemplo n.º 6
0
std::string MimetypeFromExtension( const fs::path &filepath )
{
    std::string extension = Util::BoostPathToUtf8Path( filepath.extension() );
    boost::erase_first( extension, "." );

    if ( extension == "xhtml" ||
         extension == "html"  ||
         extension == "htm" )
    {
        // Only the xhtml mimetype is valid
        // within epub, "text/html" is not
        return XHTML_MIME;
    }

    if ( extension == "png" )
    
        return PNG_MIME;    

    if ( extension == "gif" )
    
        return GIF_MIME;    

    if ( extension == "jpg" ||
         extension == "jpeg" )
    {
        return JPEG_MIME;
    }

    if ( extension == "css" )
    
        return CSS_MIME;    

    if ( extension == "ncx" )
    
        return NCX_MIME;
    
    if ( extension == "svg" )
    
        return SVG_MIME;    

    if ( extension == "otf" )
    
        return OTF_MIME;

    if ( extension == "ttf" )
    
        return TTF_MIME; 
        
    // We don't check for "xml" because
    // that's commonly used for several things.

    return UNKNOWN_MIME;
}
Exemplo n.º 7
0
Save::Save(fs::path const& file, bool binary)
: file_name(file)
, tmp_name(unique_path(file.parent_path()/(file.stem().string() + "_tmp_%%%%" + file.extension().string())))
{
	LOG_D("agi/io/save/file") << file;

	fp = agi::make_unique<boost::filesystem::ofstream>(tmp_name, binary ? std::ios::binary : std::ios::out);
	if (!fp->good()) {
		acs::CheckDirWrite(file.parent_path());
		acs::CheckFileWrite(file);
		throw fs::WriteDenied(tmp_name);
	}
}
Exemplo n.º 8
0
void SimpleViewerApp::load( fs::path path )
{
	try {
		if( path.extension() != ".svgz" ) 
			mDoc = svg::Doc::create( path );
		else // compressed
			mDoc = svg::Doc::createFromSvgz( loadFile( path ) );
		
		mTex = renderCairoToTexture( mDoc );
	}
	catch( ... ) {
	} // ignore errors
}
Exemplo n.º 9
0
void SpriteSheetGeneratorApp::addFile(const fs::path &file)
{
  set<string> extensions = { ".png", ".jpg", ".gif", ".tiff", ".tif", ".tga" };
  if( fs::exists( file ) )
  {
    cout << "Checking file: " << file << ", extension: " << file.extension().string() << endl;
    if( fs::is_regular_file( file ) && extensions.count(file.extension().string()) )
    {
      cout << "Adding file: " << file << endl;
      Surface img = loadImage( file );
      string id = file.stem().string();
      mWidestImage = max( img.getWidth(), mWidestImage );
      auto sprite = mImagePacker.addImage( id, img );
      sprite->setRegistrationPoint( Vec2i( sprite->getWidth() / 2, sprite->getHeight() ) );
    }
    else if( fs::is_directory( file ) )
    {
      for( auto iter = fs::directory_iterator( file ); iter != fs::directory_iterator(); ++iter )
      {
        addFile( *iter );
      }
    }
  }
}
/*******************************************************************
 * Function Name: GiveSegImgPath
 * Return Type 	: const fs::path
 * Created On	: Aug 21, 2013
 * Created By 	: hrushi
 * Comments		: For the given image path. It creates a segmentation folder and returns the path where the image could be stored
 * Arguments	: const fs::path& ImgPath
 *******************************************************************/
const fs::path Detect::GiveSegImgPath( const fs::path& iPath, const string Suffix)
{
	fs::path SegImgPath;


	fs::path SegFldr = iPath.parent_path().string() + "/Seg";
	fs::create_directory(SegFldr);

	string OutputPath;
	OutputPath = SegFldr.parent_path().string() + "/Seg/";
	OutputPath +=  iPath.stem().string() + Suffix;
	OutputPath +=  iPath.extension().string();

	SegImgPath = OutputPath;

	return SegImgPath;
}
Exemplo n.º 11
0
void AnimatedRevealApp::load( const fs::path &path )
{
    mMinRenderElement = 0;
    try {
        if( path.extension() == ".svgz" ) // compressed
            mDoc = svg::Doc::createFromSvgz( loadFile( path ) );
        else
            mDoc = svg::Doc::create( loadFile( path ) );

        mDone = false;
#if defined( RECORD_MOVIE )
        mMovie = qtime::MovieWriter( fs::path( getHomeDirectory() + "AnimatedReveal.mov" ), mDoc->getWidth(), mDoc->getHeight() );
#endif
    }
    catch( ci::Exception &exc ) {
        console() << "failed to load doc, what: " << exc.what() << endl;
    }
}
Exemplo n.º 12
0
unsigned OpenALAudio::load( const fs::path &filename )
{
    ALuint bufferId = 0;
    alGenBuffers( 1, &bufferId );

    FILE *file = fopen( filename.string().c_str(), "rb" );
    if ( !file )
		throw OpenALAudioExc( "Error opening " + filename.string() );

	string extension = filename.extension().string();

	if ( extension == ".ogg" )
	{
		loadOgg( filename, file, bufferId );
	}
	else
	{
		throw OpenALAudioExc( "Unknown file format " + extension );
	}

	return bufferId;
}
Exemplo n.º 13
0
bool ScanThread::isSupportedExtension(const fs::path& fileName)
{
	return extensions_.find(fileName.extension().string()) != extensions_.end();
}