Beispiel #1
0
bool MFFileNative_FindFirst(MFFind *pFind, const char *pSearchPattern, MFFindData *pFindData)
{
#if defined(_USE_CRT_FOR_NULL_DRIVERS) && defined(CRT_SUPPORTS_FIND)
	// open the directory
	_finddata_t fd;

	char *pPath = (char*)MFStr("%s%s", (char*)pFind->pMount->pFilesysData, pSearchPattern);
	intptr_t find = _findfirst(pPath, &fd);

	if(find == -1)
		return false;

	pFindData->attributes = ((fd.attrib & _A_SUBDIR) ? MFFA_Directory : 0) |
							((fd.attrib & _A_HIDDEN) ? MFFA_Hidden : 0) |
							((fd.attrib & _A_RDONLY) ? MFFA_ReadOnly : 0);
	pFindData->fileSize = fd.size;
	MFString_Copy((char*)pFindData->pFilename, fd.name);

	MFString_CopyCat(pFindData->pSystemPath, (char*)pFind->pMount->pFilesysData, pSearchPattern);
	char *pLast = MFString_RChr(pFindData->pSystemPath, '/');
	if(pLast)
		pLast[1] = 0;
	else
		pFindData->pSystemPath[0] = NULL;

	pFind->pFilesystemData = (void*)find;

	return true;
#else
	return false;
#endif
}
bool MFFileNative_FindNext(MFFind *pFind, MFFindData *pFindData)
{
	WIN32_FIND_DATA fd;

	BOOL more = FindNextFile((HANDLE)pFind->pFilesystemData, &fd);

	if(!more)
		return false;

	MFString_CopyCat(pFindData->pSystemPath, (char*)pFind->pMount->pFilesysData, pFind->searchPattern);
	char *pLast = MFString_RChr(pFindData->pSystemPath, '/');
	if(pLast)
		pLast[1] = 0;
	else
		pFindData->pSystemPath[0] = 0;

	pFindData->info.attributes = ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? MFFA_Directory : 0) |
	                             ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? MFFA_Hidden : 0) |
	                             ((fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? MFFA_ReadOnly : 0);
	pFindData->info.size = (uint64)fd.nFileSizeLow | (((uint64)fd.nFileSizeHigh) << 32);
	pFindData->info.createTime = (uint64)fd.ftCreationTime.dwHighDateTime << 32 | (uint64)fd.ftCreationTime.dwLowDateTime;
	pFindData->info.writeTime = (uint64)fd.ftLastWriteTime.dwHighDateTime << 32 | (uint64)fd.ftLastWriteTime.dwLowDateTime;
	pFindData->info.accessTime = (uint64)fd.ftLastAccessTime.dwHighDateTime << 32 | (uint64)fd.ftLastAccessTime.dwLowDateTime;
	MFString_CopyUTF16ToUTF8((char*)pFindData->pFilename, fd.cFileName);

	return true;
}
bool MFFileNative_FindFirst(MFFind *pFind, const char *pSearchPattern, MFFindData *pFindData)
{
	SceIoDirent findData;
	int findStatus;

	// separate path and search pattern..
	char *pPath = (char*)MFStr("%s/%s%s", gPSPSystemPath, (char*)pFind->pMount->pFilesysData, pSearchPattern);
	const char *pPattern = pPath;

	char *pLast = MFString_RChr(pPath, '/');
	if(pLast)
	{
		*pLast = 0;
		pPattern = pLast + 1;
	}
	else
	{
		// find pattern refers to current directory..
		pPath = ".";
	}

	// open the directory
	SceUID hFind = sceIoDopen(pPath);

	if(hFind < 0)
	{
		MFDebug_Warn(2, MFStr("Couldnt open directory '%s' with search pattern '%s'", pPath, pPattern));
		return false;
	}

	findStatus = sceIoDread(hFind, &findData);

	MFDebug_Assert(findStatus >= 0, "Error reading directory.");

	if(findStatus == 0)
		return false;

	pFindData->attributes = (FIO_SO_ISDIR(findData.d_stat.st_attr) ? MFFA_Directory : 0) |
							(FIO_SO_ISLNK(findData.d_stat.st_attr) ? MFFA_SymLink : 0);
	pFindData->fileSize = (uint64)findData.d_stat.st_size;
	MFString_Copy((char*)pFindData->pFilename, findData.d_name);

	MFString_CopyCat(pFindData->pSystemPath, (char*)pFind->pMount->pFilesysData, pSearchPattern);
	pLast = MFString_RChr(pFindData->pSystemPath, '/');
	if(pLast)
		pLast[1] = 0;
	else
		pFindData->pSystemPath[0] = 0;

	pFind->pFilesystemData = (void*)hFind;

	return true;
}
Beispiel #4
0
MFString MFString::operator+(const MFString &string) const
{
	if(string.IsEmpty())
		return *this;

	if(IsEmpty())
		return string;

	size_t bytes = pData->bytes + string.pData->bytes;

	MFString t;
    t.Reserve(bytes + 1);
	MFString_CopyCat(t.pData->pMemory, pData->pMemory, string.pData->pMemory);
	t.pData->bytes = bytes;

	return t;
}
Beispiel #5
0
MFString MFString::operator+(const char *pString) const
{
	if(!pString || *pString == 0)
		return *this;

	if(IsEmpty())
		return MFString(pString);

	size_t bytes = pData->bytes + MFString_Length(pString);

	MFString t;
    t.Reserve(bytes + 1);
	MFString_CopyCat(t.pData->pMemory, pData->pMemory, pString);
	t.pData->bytes = bytes;

	return t;
}
bool MFFileNative_FindFirst(MFFind *pFind, const char *pSearchPattern, MFFindData *pFindData)
{
	// separate path and search pattern..
	char *pPath = (char*)MFStr("%s%s", (char*)pFind->pMount->pFilesysData, pSearchPattern);
	const char *pPattern = pPath;

	char *pLast = MFString_RChr(pPath, '/');
	if(pLast)
	{
		*pLast = 0;
		pPattern = pLast + 1;
	}
	else
	{
		// find pattern refers to current directory..
		pPath = (char*)".";
	}

	// open the directory
	DIR *hFind = opendir(pPath);

	if(!hFind)
	{
		MFDebug_Warn(2, MFStr("Couldnt open directory '%s' with search pattern '%s'", pPath, pPattern));
		return false;
	}

	MFString_CopyCat(pFindData->pSystemPath, (char*)pFind->pMount->pFilesysData, pSearchPattern);
	pLast = MFString_RChr(pFindData->pSystemPath, '/');
	if(pLast)
		pLast[1] = 0;
	else
		pFindData->pSystemPath[0] = 0;

	pFind->pFilesystemData = (void*)hFind;

	bool bFound = MFFileNative_FindNext(pFind, pFindData);
	if(!bFound)
		MFFileNative_FindClose(pFind);
	return bFound;
}
bool MFFileNative_FindFirst(MFFind *pFind, const char *pSearchPattern, MFFindData *pFindData)
{
	WIN32_FIND_DATA fd;

	HANDLE hFind = FindFirstFile(MFString_UFT8AsWChar(MFStr("%s%s", (char*)pFind->pMount->pFilesysData, pSearchPattern)), &fd);

	if(hFind == INVALID_HANDLE_VALUE)
		return false;

	BOOL more = TRUE;
	while(!MFWString_Compare(fd.cFileName, L".") || !MFWString_Compare(fd.cFileName, L"..") && more)
		more = FindNextFile(hFind, &fd);
	if(!more)
	{
		FindClose(hFind);
		return false;
	}

	MFString_CopyCat(pFindData->pSystemPath, (char*)pFind->pMount->pFilesysData, pFind->searchPattern);
	char *pLast = MFString_RChr(pFindData->pSystemPath, '/');
	if(pLast)
		pLast[1] = 0;
	else
		pFindData->pSystemPath[0] = NULL;

	pFind->pFilesystemData = (void*)hFind;

	pFindData->info.attributes = ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? MFFA_Directory : 0) |
	                             ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) ? MFFA_Hidden : 0) |
	                             ((fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? MFFA_ReadOnly : 0);
	pFindData->info.size = (uint64)fd.nFileSizeLow | (((uint64)fd.nFileSizeHigh) << 32);
	pFindData->info.createTime = (uint64)fd.ftCreationTime.dwHighDateTime << 32 | (uint64)fd.ftCreationTime.dwLowDateTime;
	pFindData->info.writeTime = (uint64)fd.ftLastWriteTime.dwHighDateTime << 32 | (uint64)fd.ftLastWriteTime.dwLowDateTime;
	pFindData->info.accessTime = (uint64)fd.ftLastAccessTime.dwHighDateTime << 32 | (uint64)fd.ftLastAccessTime.dwLowDateTime;
	MFString_CopyUTF16ToUTF8((char*)pFindData->pFilename, fd.cFileName);

	return true;
}
bool MFFileNative_FindFirst(MFFind *pFind, const char *pSearchPattern, MFFindData *pFindData)
{
	WIN32_FIND_DATA fd;

	HANDLE hFind = FindFirstFile(MFStr("%s%s", (char*)pFind->pMount->pFilesysData, pSearchPattern), &fd);

	if(hFind == INVALID_HANDLE_VALUE)
		return false;

	pFindData->attributes = (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? MFFA_Directory : 0;
	pFindData->fileSize = (uint64)fd.nFileSizeLow | (((uint64)fd.nFileSizeHigh) << 32);
	MFString_Copy((char*)pFindData->pFilename, fd.cFileName);

	MFString_CopyCat(pFindData->pSystemPath, (char*)pFind->pMount->pFilesysData, pSearchPattern);
	char *pLast = MFString_RChr(pFindData->pSystemPath, '/');
	if(pLast)
		pLast[1] = 0;
	else
		pFindData->pSystemPath[0] = NULL;

	pFind->pFilesystemData = (void*)hFind;

	return true;
}