Esempio n. 1
0
void Replay::StartRecord(const FilePath & dirName)
{
    DVASSERT(!isRecord);
    DVASSERT(!isPlayback);
    isRecord = true;
    pauseReplay = false;

    FileSystem::Instance()->DeleteDirectoryFiles(dirName, false);
    FileSystem::Instance()->CreateDirectory(dirName);

    FileList * list = new FileList("~doc:/");
    int32 listSize = list->GetCount();
    for(int32 i = 0; i < listSize; ++i)
    {
        String fileName = list->GetFilename(i);
        if(!list->IsNavigationDirectory(i) && !list->IsDirectory(i) && fileName != "LastReplay.rep")
        {
            FileSystem::Instance()->CopyFile(list->GetPathname(i), dirName + fileName);
        }
    }

    list->Release();

    FilePath filePath = dirName + "LastReplay.rep";
    file = File::Create(filePath, File::CREATE | File::WRITE);

    Random::Instance()->Seed();
}
Esempio n. 2
0
uint32 FileSystem::DeleteDirectoryFiles(const String & path, bool isRecursive)
{
	uint32 fileCount = 0; 
	
	FileList * fileList = new FileList(path);
	for(int i = 0; i < fileList->GetCount(); ++i)
	{
		if(fileList->IsDirectory(i))
		{
			if(!fileList->IsNavigationDirectory(i))
			{
				if(isRecursive)
				{
					fileCount += DeleteDirectoryFiles(fileList->GetPathname(i), isRecursive);
				}
			}
		}
		else 
		{
			bool success = DeleteFile(fileList->GetPathname(i));
			if(success)fileCount++;
		}
	}
	SafeRelease(fileList);

	return fileCount;
}
Esempio n. 3
0
void Replay::StartPlayback(const FilePath & dirName)
{
    DVASSERT(!isRecord);
    DVASSERT(!isPlayback);
    pauseReplay = false;
    isPlayback = true;

    FileSystem::Instance()->DeleteDirectoryFiles("~doc:/", false);
    FileList * list = new FileList(dirName);
    int32 listSize = list->GetCount();
    for(int32 i = 0; i < listSize; ++i)
    {
        String fileName = list->GetFilename(i);
        if(!list->IsNavigationDirectory(i) && !list->IsDirectory(i))
        {
            FilePath existingFile = dirName + fileName;
            FilePath newFile("~doc:/" + fileName);

            FileSystem::Instance()->CopyFile(existingFile, newFile);
        }
    }

    list->Release();


    skipType = false;
    file = File::Create("~doc:/LastReplay.rep", File::OPEN | File::READ);
}
Esempio n. 4
0
void UIFileTree::RecursiveTreeWalk(const String & path, UITreeItemInfo * current)
{
	FileList * fileList = new FileList(path);
	
	// Find flags and setup them
	for (int fi = 0; fi < fileList->GetCount(); ++fi)
	{
		bool addElement = true;
		if (!fileList->IsDirectory(fi))
		{
			size_t extsSize = extensions.size();
			if (extsSize > 0)
			{
				addElement = false;
				String ext = FileSystem::GetExtension(fileList->GetFilename(fi));
				for (size_t ei = 0; ei < extsSize; ++ei)
					if (extensions[ei] == ext)
					{
						addElement = true;
						break;
					}
			}
		}
		if (!isFolderNavigationEnabled)
			if (fileList->IsNavigationDirectory(fi))
				addElement = false;

		if (fileList->GetFilename(fi) == ".")
			addElement = false;

		if (addElement)
		{
			UITreeItemInfo *child = new UITreeItemInfo(this);
			child->Set(current->GetLevel() + 1, fileList->GetFilename(fi), fileList->GetPathname(fi), fileList->IsDirectory(fi));
			current->AddChild(child);

//			if (fileList->IsDirectory(fi) )
//			{
//				if (!fileList->IsNavigationDirectory(fi))
//				{
//					RecursiveTreeWalk(path + String("/") + fileList->GetFilename(fi), child);
//				}
//			}
		}
	}
	SafeRelease(fileList);
}
Esempio n. 5
0
bool FileSystem::DeleteDirectory(const String & path, bool isRecursive)
{
	FileList * fileList = new FileList(path);
	for(int i = 0; i < fileList->GetCount(); ++i)
	{
		if(fileList->IsDirectory(i))
		{
			if(!fileList->IsNavigationDirectory(i))
			{
				if(isRecursive)
				{
//					Logger::Debug("- try to delete directory: %s / %s", fileList->GetPathname(i).c_str(), fileList->GetFilename(i).c_str());
					bool success = DeleteDirectory(fileList->GetPathname(i), isRecursive);
//					Logger::Debug("- delete directory: %s / %s- %d", fileList->GetPathname(i).c_str(), fileList->GetFilename(i).c_str(), success ? (1): (0));
					if (!success)return false;
				}
			}
		}
		else 
		{
			bool success = DeleteFile(fileList->GetPathname(i));
//			Logger::Debug("- delete file: %s / %s- %d", fileList->GetPathname(i).c_str(), fileList->GetFilename(i).c_str(), success ? (1): (0));
			if(!success)return false;
		}
	}
	SafeRelease(fileList);
#ifdef __DAVAENGINE_WIN32__
	String sysPath = SystemPathForFrameworkPath(path);
	int32 chmodres = _chmod(sysPath.c_str(), _S_IWRITE); // change read-only file mode
	int32 res = _rmdir(sysPath.c_str());
	return (res == 0);
	/*int32 res = ::RemoveDirectoryA(path.c_str());
	if (res == 0)
	{
		Logger::Warning("Failed to delete directory: %s error: 0x%x", path.c_str(), GetLastError());
	}
	return (res != 0);*/
#elif defined(__DAVAENGINE_MACOS__) || defined(__DAVAENGINE_IPHONE__) || defined(__DAVAENGINE_ANDROID__)
	int32 res = rmdir(SystemPathForFrameworkPath(path).c_str());
	return (res == 0);
#endif //PLATFORMS
}