Esempio n. 1
0
u32 vfsDevice::CmpLocalPath(const std::string& local_path)
{
	if(local_path.length() < m_local_path.length())
		return 0;

	rFileName path0(m_local_path);
	path0.Normalize();

#ifdef _WIN32
#define DL "\\"
#else
#define DL "/"
#endif

	std::vector<std::string> arr0 = fmt::rSplit(path0.GetFullPath(), DL);
	std::vector<std::string> arr1 = fmt::rSplit(local_path, DL);

	const u32 lim = std::min(arr0.size(), arr1.size());
	u32 ret = 0;

	for(u32 i=0; i<lim; ret += arr0[i++].size() + 1)
	{
		if(fmt::CmpNoCase(arr0[i],arr1[i]) != 0)
		{
			break;
		}
	}

	return ret;
}
Esempio n. 2
0
        /**
         * Helper function for Ignite home resolution.
         * Goes upwards in directory hierarchy and checks whether certain
         * folders exist in the path.
         *
         * @param path Path to evaluate.
         * @return res Resolved directory. Empty string if not found.
         */
        std::string ResolveIgniteHome0(const std::string& path)
        {
            if (!IsValidDirectory(path))
                return std::string();

            // Remove trailing slashes, otherwise we will have an infinite loop.
            size_t last = path.find_last_not_of("/\\ ");

            if (last == std::string::npos)
                return std::string();

            std::string path0(path, 0, last + 1);

            if (LooksLikeBinaryReleaseHome(path0) || LooksLikeSourceReleaseHome(path0))
                return path0;

            // Evaluate parent directory.
            size_t slashPos = path0.find_last_of("/\\");

            if (slashPos == std::string::npos)
                return std::string();

            std::string parent(path0, 0, slashPos);

            return ResolveIgniteHome0(parent);
        }
Esempio n. 3
0
bool PrinterData::getPath(string &path) const
{
    if (fNode == NULL) return false;

    node_ref nref;
    if (fNode->GetNodeRef(&nref) != B_OK) return false;

    BDirectory dir(&nref);
    if (dir.InitCheck() != B_OK) return false;

    BPath path0(&dir, ".");
    if (path0.InitCheck() != B_OK) return false;

    path = path0.Path();
    return true;
}
	TEST_F(FSTestFixture, getAllFiles_without_extsFilter)
	{
		std::vector<Path> content;
		std::vector<Path> content0;

		Path path(getTestDirectory().string(), "", false);
		Path path0((getTestDirectory() / "0").string(), "", false);

		getAllFiles(path, content, nullptr);
		getAllFiles(path0, content0, nullptr);

		ASSERT_EQ(content.size(), 0);
		ASSERT_EQ(content0.size(), 4);


		ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / "0").string(), "", true), content0));
		ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / "1.txt").string(), "", true), content0));
		ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / "2.png").string(), "", true), content0));
		ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / UNICODE_EXAMPLE_FILE).string(), "", true), content0));
	}
Esempio n. 5
0
        bool DeletePath(const std::string& path)
        {
            std::vector<TCHAR> path0(path.begin(), path.end());
            path0.push_back('\0');
            path0.push_back('\0');

            SHFILEOPSTRUCT fileop;
            fileop.hwnd = NULL;
            fileop.wFunc = FO_DELETE;
            fileop.pFrom = &path0[0];
            fileop.pTo = NULL;
            fileop.fFlags = FOF_NOCONFIRMATION | FOF_SILENT;

            fileop.fAnyOperationsAborted = FALSE;
            fileop.lpszProgressTitle = NULL;
            fileop.hNameMappings = NULL;

            int ret = SHFileOperation(&fileop);

            return ret == 0;
        }