示例#1
0
bool LongFile::IsPathNotFullyQualified(const pal::string_t& path)
{
    if (path.length() < 2)
    {
        return true;  // It isn't fixed, it must be relative.  There is no way to specify a fixed path with one character (or less).
    }

    if (IsDirectorySeparator(path[0]))
    {
        return !IsDirectorySeparator(path[1]); // There is no valid way to specify a relative path with two initial slashes
    }

    return !((path.length() >= 3)           //The only way to specify a fixed path that doesn't begin with two slashes is the drive, colon, slash format- "i.e. C:\"
        && (path[1] == VolumeSeparatorChar)
        && IsDirectorySeparator(path[2]));
}
示例#2
0
static bool IsInFilesDirectory(const std::string& path)
{
  size_t files_pos = std::string::npos;
  while (true)
  {
    files_pos = path.rfind("files", files_pos);
    if (files_pos == std::string::npos)
      return false;

    const size_t slash_before_pos = files_pos - 1;
    const size_t slash_after_pos = files_pos + 5;
    if ((files_pos == 0 || IsDirectorySeparator(path[slash_before_pos])) &&
        (slash_after_pos == path.size() || (IsDirectorySeparator(path[slash_after_pos]))) &&
        ExistsAndIsValidDirectoryBlob(path.substr(0, files_pos) + "sys/main.dol"))
    {
      return true;
    }

    --files_pos;
  }
}
bool FileSystemDefault::MakeDirectory(const char* path)
{
	// 05/02/2011 - This function is now smart enough to create multiple levels
	// of directories.

	if(path && *path)
	{
		//Fast case - where we may be creating only a top level directory
		if(!DirectoryExists(path))
			MakeDirectoryInternal(path);

		if(DirectoryExists(path))
			return true;

		
		
		//Slow case - where we may be creating multiple levels of directory

		char path8[EA::WebKit::FileSystem::kMaxPathLength];
		const size_t nStrlen = strlen(path);
		EAW_ASSERT_MSG(nStrlen < EA::WebKit::FileSystem::kMaxPathLength, "Directory path exceeds max path length");
		strncpy(path8, path, EA::WebKit::FileSystem::kMaxPathLength);
		path8[EA::WebKit::FileSystem::kMaxPathLength-1] = 0;

		char8_t* p    = path8;
		char8_t* pEnd = path8 + nStrlen; 

#if defined(EA_PLATFORM_WINDOWS) // Windows has the concept of UNC paths which begin with two back slashes \\server\dir\dir
		if(IsDirectorySeparator(*p))
		{
			if(IsDirectorySeparator(*++p)) // Move past an initial path separator.
				++p;
		}
#endif

#if defined(EA_PLATFORM_MICROSOFT)
		// 05/03/2011 - abaldeva: Fix a bug which could otherwise result in incorrect behavior on Xenon.
		char* rootDrive = strchr(p, ':');
		if(rootDrive)
		{
			p = ++rootDrive;
			while(IsDirectorySeparator(*p))
				++p;
		}
		/* //Old code
		if(p[0] && (p[1] == ':') && IsDirectorySeparator(p[2])) // Move past an initial C:/
			p += 3;
		*/
#else
		if(IsDirectorySeparator(*p)) // Move past an initial path separator.
			++p;
#endif

		if(IsDirectorySeparator(pEnd[-1])) // Remove a trailing path separator if present.
			pEnd[-1] = 0;

		for(; *p; ++p) // Walk through the path, creating each component of it if necessary.
		{
			if(IsDirectorySeparator(*p))
			{
				*p = 0;

				if(!DirectoryExists(path8))
				{
					if(!MakeDirectoryInternal(path8))//05/02/11 - abaldeva: Fix a bug otherwise multiple directories are not created.
						return false;
				}

				*p = kDirectorySeparator;
			}
		}

		if(!DirectoryExists(path8))
		{
			if(!MakeDirectoryInternal(path8))//05/02/11 - abaldeva: Fix a bug otherwise multiple directories are not created.
				return false;
		}

		return true; //12/20/11 - abaldeva: Fix a bug otherwise though multiple directories are created, the API returns false.

	}
	
	
	return false;
}
示例#4
0
static bool PathCharactersEqual(char a, char b)
{
  return a == b || (IsDirectorySeparator(a) && IsDirectorySeparator(b));
}