Exemplo n.º 1
0
void ExtCommandsHandler::handleGenShareLink(const QStringList& args)
{
    if (args.size() != 1) {
        return;
    }
    QString path = normalizedPath(args[0]);
    foreach (const LocalRepo& repo, listLocalRepos()) {
        QString wt = normalizedPath(repo.worktree);
        // qDebug("path: %s, repo: %s", path.toUtf8().data(), wt.toUtf8().data());
        if (path.length() > wt.length() && path.startsWith(wt) and path.at(wt.length()) == '/') {
            QString path_in_repo = path.mid(wt.size());
            bool is_file = QFileInfo(path).isFile();
            emit generateShareLink(repo.id, path_in_repo, is_file);
            break;
        }
    }
Exemplo n.º 2
0
void fcFileOpener::AddExcludePath(const std::string& path)
{
	std::string normalizedPath ( path );
	normalize_path( normalizedPath );

	if ( IsExcludePathExist(normalizedPath) ) {
		return;
	}
	_excludePaths.push_back(normalizedPath);
}
Exemplo n.º 3
0
std::string NormalizePath(const std::string& path)
{
	std::string normalizedPath(path);
	
	for(size_t i = 0; i < path.size(); i++)
	{
		if(path[i] == '/' || ( i + 1 < path.size() && path[i] == ':' && !(path[i + 1] == '\\' || path[i + 1] == '/') ))
			normalizedPath[i] = '\\';
		else
			normalizedPath[i] = path[i];
	}

	return normalizedPath;

}
Exemplo n.º 4
0
std::string getThisDllPath()
{
    static char module_filename[MAX_PATH] = { 0 };

    if (module_filename[0] == '\0') {
        DWORD module_size;
        module_size = GetModuleFileName(
            g_hmodThisDll, module_filename, MAX_PATH);
        if (!module_size)
            return "";

        normalizedPath(module_filename);
    }

    return module_filename;
}
Exemplo n.º 5
0
std::string splitPath(const std::string& path, int *pos)
{
    if (path.size() == 0) {
        return "";
    }

    std::string p = normalizedPath(path);
    while (p.size() > 1 && p[-1] == '/') {
        p = p.substr(0, p.size() - 1);
    }
    if (p.size() == 1) {
        return p;
    }

    *pos = p.rfind("/");
    return p;
}
const BundleDescriptorReader::BundleContainer BundleDescriptorReader::createBundles(const ::boost::filesystem::path& location) throw(RuntimeException)
{
    // Normalizes the path.
    ::boost::filesystem::path normalizedPath(location);
    normalizedPath.normalize();

    // Asserts that the repository is a valid directory path.
    if(::boost::filesystem::exists(normalizedPath) == false || ::boost::filesystem::is_directory(normalizedPath) == false)
    {
        throw RuntimeException("'" + normalizedPath.string() + "': not a directory.");
    }

    // Walk through the repository entries.
    BundleContainer bundles;
    ::boost::filesystem::directory_iterator   currentEntry(normalizedPath);
    ::boost::filesystem::directory_iterator   endEntry;
    for(; currentEntry != endEntry; ++currentEntry)
    {
        ::boost::filesystem::path entryPath = *currentEntry;

        if(::boost::filesystem::is_directory(entryPath))
        {
            try
            {
                SPTR( ::fwRuntime::Bundle ) bundle = BundleDescriptorReader::createBundle(entryPath);
                if(bundle)
                {
                    bundles.push_back( bundle );
                }
            }
            catch(const RuntimeException& runtimeException)
            {
                OSLM_INFO( "'"<< entryPath.string() << "': skipped. " << runtimeException.what() );
            }
        }
    }
    return bundles;
}