Ejemplo n.º 1
0
bool NavigationCell::ForcePointToCellCollumn(vector2& TestPoint)const
{
	bool PointAltered = false;

	// create a motion path from the center of the cell to our point
	Line2D TestPath(vector2(m_CenterPoint.x, m_CenterPoint.z), TestPoint);
	vector2 PointOfIntersection;
	CELL_SIDE Side;
	NavigationCell* NextCell;

	PATH_RESULT result = ClassifyPathToCell(TestPath, &NextCell, Side, &PointOfIntersection);
	// compare this path to the cell.

	if (result == EXITING_CELL)
	{
		vector2 PathDirection(PointOfIntersection.x - m_CenterPoint.x, PointOfIntersection.y - m_CenterPoint.z);

		PathDirection *= 0.9f;

		TestPoint.x = m_CenterPoint.x + PathDirection.x;
		TestPoint.y = m_CenterPoint.z + PathDirection.y;
		return (true);
	}
	else if (result == NO_RELATIONSHIP)
	{
		TestPoint.x = m_CenterPoint.x;
		TestPoint.y = m_CenterPoint.z;
		return (true);
	}

	return (false);
}
Ejemplo n.º 2
0
//--------------------------------------------------------------------------
bool VeFilePath::HasSubDir(const VeChar8* pcDir) const noexcept
{
	VeChar8 acBuffer[VE_MAX_PATH_LEN];
	PATH_CAT(acBuffer, m_kPath, pcDir);
	PathInfo kInfo;
	if (TestPath(acBuffer, kInfo))
	{
		return VE_MASK_HAS_ALL(kInfo.m_stAttrib, VE_A_SUBDIR);
	}
	return false;
}
Ejemplo n.º 3
0
//--------------------------------------------------------------------------
VeBinaryIStreamPtr VeFilePath::CreateStream(const VeChar8* pcPath) noexcept
{
	PathInfo kInfo;
	if (TestPath(pcPath, kInfo))
	{
		if (VE_MASK_HAS_ALL(kInfo.m_stAttrib, VE_A_ARCH))
		{
			return VE_NEW VeFileIStream(pcPath);
		}
	}
	return nullptr;
}
Ejemplo n.º 4
0
 TestData()
 : fRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
                              SkIntToScalar(2), SkIntToScalar(1)))
 , fMatrix(TestMatrix())
 , fPath(TestPath())
 , fNearlyZeroLengthPath(TestNearlyZeroLengthPath())
 , fIRect(SkIRect::MakeXYWH(0, 0, 2, 1))
 , fRegion(TestRegion())
 , fColor(0x01020304)
 , fPoints(kTestPoints)
 , fPointCount(3)
 , fWidth(2)
 , fHeight(2)
 , fText("Hello World")
 , fPoints2(kTestPoints2)
 , fBitmap(TestBitmap())
 { }
Ejemplo n.º 5
0
//-------------------------------------------------------------
// Post    : Return TRUE if directory exists
// Task    : To determine if the directory exists, we need to
//           create a test path with a wildcard (*.*) extension
//           and see if FindFirstFile returns anything.  We don't
//           use CPath::FindFirst() because that routine parses out
//           '.' and '..', which fails for empty directories
//-------------------------------------------------------------
bool CPath::DirectoryExists() const
{
    // Create test path
    CPath TestPath(m_strPath.c_str());

    std::string DirName;
    TestPath.UpDirectory(&DirName);
    TestPath.SetNameExtension(DirName.c_str());

    WIN32_FIND_DATA	FindData;
    HANDLE          hFindFile =FindFirstFile((const char *)TestPath,&FindData); // Find anything
    bool            bGotFile  =(hFindFile != INVALID_HANDLE_VALUE);

    if(hFindFile != NULL)	// Make sure we close the search
        FindClose(hFindFile);

    return bGotFile;
}
Ejemplo n.º 6
0
//--------------------------------------------------------------------------
VeDirectoryPtr VeFilePath::Create(const VeChar8* pcPath,
	bool bTryCreate) noexcept
{
	PathInfo kInfo;
	if (TestPath(pcPath, kInfo))
	{
		if (VE_MASK_HAS_ALL(kInfo.m_stAttrib, VE_A_SUBDIR))
		{
			return VE_NEW VeFilePath(pcPath);
		}
		else if(VE_MASK_HAS_ALL(kInfo.m_stAttrib, VE_A_ARCH))
		{
			return nullptr;
		}
	}
	else if(bTryCreate && CreatePath(pcPath))
	{
		return VE_NEW VeFilePath(pcPath);
	}
	return nullptr;
}
Ejemplo n.º 7
0
static void TestUnixStyleAppends(void)
{
    LE_INFO("======== Test Unix Style Appends.");

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "x/y/z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/a/b/c/x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "../x/y/z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/a/b/x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "../../x/y/z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/a/x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "../../../x/y/z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "../../../../x/y/z") == LE_UNDERFLOW);
        LE_TEST(TestPath(iteratorRef, "/"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "../../../x/y/z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "../../../../x/y/z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "../x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "/x/y/z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "/x/y/z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("a/b/c");
        LE_TEST(le_pathIter_Append(iteratorRef, "./x/y/z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "a/b/c/x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("");
        LE_TEST(le_pathIter_Append(iteratorRef, "./x/y/./z") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "./x/y/z"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("");
        LE_TEST(le_pathIter_Append(iteratorRef, "/a//path/to/a///some/../place") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/a/path/to/a/place"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_Create("", "::", "^^", "__");
        LE_TEST(le_pathIter_Append(iteratorRef, "__::a::::path::to::__::a::some::^^::place") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "__::a::path::to::a::place"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_Create("::", "::", "^^", "__");
        LE_TEST(le_pathIter_Append(iteratorRef, "__::a::::path::to::__::a::some::^^::place") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "::a::path::to::a::place"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_Create("", "/", NULL, NULL);
        LE_TEST(le_pathIter_Append(iteratorRef, "/a//path/./to/a///some/../place") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/a/path/./to/a/some/../place"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("");
        LE_TEST(le_pathIter_Append(iteratorRef, "../../../a//path/") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "../../../a/path"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("");
        LE_TEST(le_pathIter_Append(iteratorRef, "/a//path/to/a///some/../place") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/a/path/to/a/place"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);

        LE_TEST(le_pathIter_GoToStart(iteratorRef) == LE_OK);

        LE_TEST(le_pathIter_GoToNext(iteratorRef) == LE_OK);
        LE_TEST(le_pathIter_GoToNext(iteratorRef) == LE_OK);
        LE_TEST(le_pathIter_GoToNext(iteratorRef) == LE_OK);

        le_pathIter_Truncate(iteratorRef);

        LE_TEST(le_pathIter_Append(iteratorRef, "nowhere") == LE_OK);

        LE_TEST(TestPath(iteratorRef, "/a/path/to/nowhere"));

        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("");
        LE_TEST(le_pathIter_Append(iteratorRef, "/a//path/to/a///some/../place") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/a/path/to/a/place"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);

        LE_TEST(le_pathIter_Append(iteratorRef, "../../nowhere") == LE_OK);

        LE_TEST(TestPath(iteratorRef, "/a/path/to/nowhere"));

        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a/b/c");
        LE_TEST(TestPath(iteratorRef, "/a/b/c"));
        LE_TEST(le_pathIter_Append(iteratorRef, "..") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/a/b"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a/b/c/");
        LE_TEST(TestPath(iteratorRef, "/a/b/c"));
        LE_TEST(le_pathIter_Append(iteratorRef, "..") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/a/b"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("a/b/c");
        LE_TEST(TestPath(iteratorRef, "a/b/c"));
        LE_TEST(le_pathIter_Append(iteratorRef, "..") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "a/b"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("a/b/c/");
        LE_TEST(TestPath(iteratorRef, "a/b/c"));
        LE_TEST(le_pathIter_Append(iteratorRef, "..") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "a/b"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a");
        LE_TEST(TestPath(iteratorRef, "/a"));
        LE_TEST(le_pathIter_Append(iteratorRef, "..") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("/a/");
        LE_TEST(TestPath(iteratorRef, "/a"));
        LE_TEST(le_pathIter_Append(iteratorRef, "..") == LE_OK);
        LE_TEST(TestPath(iteratorRef, "/"));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == true);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("a");
        LE_TEST(TestPath(iteratorRef, "a"));
        LE_TEST(le_pathIter_Append(iteratorRef, "..") == LE_OK);
        LE_TEST(TestPath(iteratorRef, ""));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }

    {
        le_pathIter_Ref_t iteratorRef = le_pathIter_CreateForUnix("a/");
        LE_TEST(TestPath(iteratorRef, "a"));
        LE_TEST(le_pathIter_Append(iteratorRef, "..") == LE_OK);
        LE_TEST(TestPath(iteratorRef, ""));
        LE_TEST(le_pathIter_IsAbsolute(iteratorRef) == false);
        le_pathIter_Delete(iteratorRef);
    }
}