コード例 #1
0
ファイル: OsFileSystem.cpp プロジェクト: Konnekt/lib-sipx
//: Removes the directory or file specified by path
OsStatus OsFileSystem::remove(const OsPath& path, UtlBoolean bRecursive, UtlBoolean bForce)
{
    OsStatus retval = OS_INVALID;
    OsFileInfo info;
    OsPath testpath = path;
    getFileInfo(testpath,info);

    if (info.isDir())
    {
        if (bRecursive)
        {
            retval = removeTree(path,bForce);
        }
        else
        {
            if (rmdir((char *)path.data()) != -1)
                retval = OS_SUCCESS;
        }
    }
    else
    {
        if (bForce)
            setReadOnly(path,FALSE);
        if (::remove(path.data()) != -1)
            retval = OS_SUCCESS;
    }

    return retval;
}
コード例 #2
0
ファイル: Loaders.cpp プロジェクト: Bigpet/ppsspp
bool LocalFileLoader::IsDirectory() {
	FileInfo info;
	if (getFileInfo(filename_.c_str(), &info)) {
		return info.isDirectory;
	}
	return false;
}
コード例 #3
0
ファイル: OsFileLinux.cpp プロジェクト: Konnekt/lib-sipx
UtlBoolean OsFileLinux::isReadonly() const
{
    OsFileInfoLinux info;
    getFileInfo(info);

    return info.mbIsReadOnly;
}
コード例 #4
0
int main(int argc, char *argv[]){
    int n;
    struct Filethings f[BUF_LENGTH];
    calling(argv[1]);
    n=getFileInfo(f);
    //compareFile(f,n,argv[1]);
        }
コード例 #5
0
ファイル: sceUmd.cpp プロジェクト: 716Girl/ppsspp
void __UmdReplace(std::string filepath) {
	// Only get system from disc0 seems have been enough.
	IFileSystem* currentUMD = pspFileSystem.GetSystem("disc0:");
	if (!currentUMD)
		return;

	IFileSystem* umd2;
	FileInfo info;
	if (!getFileInfo(filepath.c_str(), &info))    // This shouldn't happen, but for safety.
		return;
	if (info.isDirectory) {
		umd2 = new VirtualDiscFileSystem(&pspFileSystem, filepath);
	} else {
		auto bd = constructBlockDevice(filepath.c_str());
		if (!bd)
			return;
		umd2 = new ISOFileSystem(&pspFileSystem, bd);

		pspFileSystem.Remount(currentUMD, umd2);
	}
	delete currentUMD;

	// TODO Is this always correct if UMD was not activated?
	u32 notifyArg = PSP_UMD_PRESENT | PSP_UMD_READABLE | PSP_UMD_CHANGED;
	if (driveCBId != -1)
		__KernelNotifyCallback(driveCBId, notifyArg);
}
コード例 #6
0
ファイル: WindowsHost.cpp プロジェクト: ANR2ME/ppsspp
static std::string SymbolMapFilename(const char *currentFilename, char* ext)
{
	FileInfo info;

	std::string result = currentFilename;

	// can't fail, definitely exists if it gets this far
	getFileInfo(currentFilename, &info);
	if (info.isDirectory)
	{
#ifdef _WIN32
		char* slash = "\\";
#else
		char* slash = "/";
#endif
		if (!endsWith(result,slash))
			result += slash;

		return result + ".ppsspp-symbols" + ext;
	} else {
		size_t dot = result.rfind('.');
		if (dot == result.npos)
			return result + ext;

		result.replace(dot, result.npos, ext);
		return result;
	}
}
コード例 #7
0
void ReplayWindow::openReplay(String path)
{
  if (FileInfo* info = (replay ? replay->getFileInfo() : NULL))
  {
    if (info->path.icompare(path) == 0)
    {
      FileInfo cur;
      getFileInfo(path, cur);
      if (cur.ftime == info->ftime)
        return;
    }
  }
  delete replay;
  viewItem = NULL;
  uint32 error;
  replay = W3GReplay::load(path, false, &error);
  if (replay == NULL)
  {
    switch (error)
    {
    case W3GReplay::eNoFile:
      failureInfo->setText("File not found");
      break;
    case W3GReplay::eBadFile:
      failureInfo->setText("Failed to parse file");
      break;
    case W3GReplay::eNoMap:
      failureInfo->setText("No map data");
      break;
    }
    failureInfo->resetSize();
  }
  update();
}
コード例 #8
0
ファイル: GameInfoCache.cpp プロジェクト: BlueSplash/ppsspp
u64 GameInfo::GetInstallDataSizeInBytes() {
	if (fileType == FILETYPE_PSP_SAVEDATA_DIRECTORY || fileType == FILETYPE_PPSSPP_SAVESTATE) {
		return 0;
	}
	std::vector<std::string> saveDataDir = GetSaveDataDirectories();

	u64 totalSize = 0;
	u64 filesSizeInDir = 0;
	for (size_t j = 0; j < saveDataDir.size(); j++) {
		std::vector<FileInfo> fileInfo;
		getFilesInDir(saveDataDir[j].c_str(), &fileInfo);
		// Note: getFileInDir does not fill in fileSize properly.
		for (size_t i = 0; i < fileInfo.size(); i++) {
			FileInfo finfo;
			getFileInfo(fileInfo[i].fullName.c_str(), &finfo);
			if (!finfo.isDirectory)
				filesSizeInDir += finfo.size;
		}
		if (filesSizeInDir >= 0xA00000) { 
			// HACK: Generally the savedata size in a dir shouldn't be more than 10MB.
			// This is probably GameInstall data.
			totalSize += filesSizeInDir;
		}
		filesSizeInDir = 0;
	}
	return totalSize;
}
コード例 #9
0
ファイル: zvolume.cpp プロジェクト: nanzhang790/View3dn
bool CVolume3D::_loadRAWFile(const char *fname)
{
	int bpv;	//bytes per voxel
	if (!getFileInfo(fname, m_nx, m_ny, m_nz, bpv, m_vBrickBuffer, m_nBrick)){
		printf("Cannot find the info file associated with %s.\n", fname);
		return false;
	}

	m_nxy = m_nx*m_ny;	
	FILE *fp = fopen(fname, _RB_);
	if (fp==NULL) return false;
	const int nsize = m_nx*m_ny*m_nz;
	m_pDensityVolume = (float*)(new unsigned char [nsize*bpv]);
	fread(m_pDensityVolume, bpv*m_nx, m_ny*m_nz, fp);
	fclose(fp);

	switch(bpv){
		case 1:
			{
				float *p=convertByteToFloat((unsigned char*)m_pDensityVolume, m_nx, m_ny, m_nz);
				delete [] m_pDensityVolume;
				m_pDensityVolume =p;
				break;
			}
		case 4:
			break;
	}
	m_nDensityVolumeType = GL_FLOAT;
	return true;
}
コード例 #10
0
ファイル: Loaders.cpp プロジェクト: DonelBueno/ppsspp
bool LoadFile(std::string &filename, std::string *error_string) {
	INFO_LOG(LOADER,"Identifying file...");
	// Note that this can modify filename!
	switch (Identify_File(filename)) {
	case FILETYPE_PSP_PBP_DIRECTORY:
		{
			std::string ebootFilename = filename + "/EBOOT.PBP";
			FileInfo fileInfo;
			getFileInfo((filename + "/EBOOT.PBP").c_str(), &fileInfo);

			if (fileInfo.exists) {
				INFO_LOG(LOADER, "File is a PBP in a directory!");
				std::string path = filename;
				size_t pos = path.find("/PSP/GAME/");
				if (pos != std::string::npos)
					pspFileSystem.SetStartingDirectory("ms0:" + path.substr(pos));
				return Load_PSP_ELF_PBP(ebootFilename.c_str(), error_string);
			} else {
				*error_string = "No EBOOT.PBP, misidentified game";
				return false;
			}
		}

	case FILETYPE_PSP_PBP:
	case FILETYPE_PSP_ELF:
		{
			INFO_LOG(LOADER,"File is an ELF or loose PBP!");
			return Load_PSP_ELF_PBP(filename.c_str(), error_string);
		}

	case FILETYPE_PSP_ISO:
	case FILETYPE_PSP_ISO_NP:
	case FILETYPE_PSP_DISC_DIRECTORY:	// behaves the same as the mounting is already done by now
		pspFileSystem.SetStartingDirectory("disc0:/PSP_GAME/USRDIR");
		return Load_PSP_ISO(filename.c_str(), error_string);

	case FILETYPE_ERROR:
		ERROR_LOG(LOADER, "Could not read file");
		*error_string = "Error reading file";
		break;

	case FILETYPE_ARCHIVE_RAR:
		*error_string = "File is compressed (RAR).\nPlease decompress first (try WinRAR)";
		break;

	case FILETYPE_ARCHIVE_ZIP:
		*error_string = "File is compressed (ZIP).\nPlease decompress first (try WinRAR)";
		break;

	case FILETYPE_UNKNOWN_BIN:
	case FILETYPE_UNKNOWN_ELF:
	case FILETYPE_UNKNOWN:
	default:
		ERROR_LOG(LOADER, "Failed to identify file");
		*error_string = "Failed to identify file";
		break;
	}
	return false;
}
コード例 #11
0
bool LocalFileLoader::Exists() {
	// If we couldn't open it for reading, we say it does not exist.
	if (f_ || IsDirectory()) {
		FileInfo info;
		return getFileInfo(filename_.c_str(), &info);
	}
	return false;
}
コード例 #12
0
void auditPrepare()
{
	getAllRomsetInfo();
	clearAllRomsetState();

	freeArchiveList();
	getFileInfo(false);
}
コード例 #13
0
ファイル: PSPLoaders.cpp プロジェクト: CLYBOY/ppsspp
// We gather the game info before actually loading/booting the ISO
// to determine if the emulator should enable extra memory and
// double-sized texture coordinates.
void InitMemoryForGameISO(std::string fileToStart) {
	IFileSystem* umd2;

	// check if it's a disc directory
	FileInfo info;
	if (!getFileInfo(fileToStart.c_str(), &info)) return;

	if (info.isDirectory)
	{
		umd2 = new VirtualDiscFileSystem(&pspFileSystem, fileToStart);
	}
	else 
	{
		auto bd = constructBlockDevice(fileToStart.c_str());
		// Can't init anything without a block device...
		if (!bd)
			return;
		umd2 = new ISOFileSystem(&pspFileSystem, bd);
	}

	// Parse PARAM.SFO

	//pspFileSystem.Mount("host0:",umd2);
	pspFileSystem.Mount("umd0:", umd2);
	pspFileSystem.Mount("umd1:", umd2);
	pspFileSystem.Mount("disc0:", umd2);
	pspFileSystem.Mount("umd:", umd2);

	std::string gameID;

	std::string sfoPath("disc0:/PSP_GAME/PARAM.SFO");
	PSPFileInfo fileInfo = pspFileSystem.GetFileInfo(sfoPath.c_str());

	if (fileInfo.exists)
	{
		u8 *paramsfo = new u8[(size_t)fileInfo.size];
		u32 fd = pspFileSystem.OpenFile(sfoPath, FILEACCESS_READ);
		pspFileSystem.ReadFile(fd, paramsfo, fileInfo.size);
		pspFileSystem.CloseFile(fd);
		if (g_paramSFO.ReadSFO(paramsfo, (size_t)fileInfo.size))
		{
			gameID = g_paramSFO.GetValueString("DISC_ID");

			for (size_t i = 0; i < ARRAY_SIZE(g_HDRemasters); i++) {
				if(g_HDRemasters[i].gameID == gameID) {
					g_RemasterMode = true;
					Memory::g_MemorySize = g_HDRemasters[i].MemorySize;
					if(g_HDRemasters[i].DoubleTextureCoordinates)
						g_DoubleTextureCoordinates = true;
					break;
				}
			}
			DEBUG_LOG(LOADER, "HDRemaster mode is %s", g_RemasterMode? "true": "false");
		}
		delete [] paramsfo;
	}
}
コード例 #14
0
bool getFileModificationTime(const String& path, time_t& time)
{
    BY_HANDLE_FILE_INFORMATION fileInformation;
    if (!getFileInfo(path, fileInformation))
        return false;

    getFileModificationTimeFromFileInfo(fileInformation, time);
    return true;
}
コード例 #15
0
bool getFileSize(const String& path, long long& size)
{
    BY_HANDLE_FILE_INFORMATION fileInformation;
    if (!getFileInfo(path, fileInformation))
        return false;

    getFileSizeFromFileInfo(fileInformation, size);
    return true;
}
コード例 #16
0
ファイル: OsFileWnt.cpp プロジェクト: Jaroslav23/sipxtapi
UtlBoolean OsFileWnt::isReadonly() const
{
    UtlBoolean retval = FALSE;
    
    OsFileInfoWnt info;
    getFileInfo(info);
    
    return info.mbIsReadOnly;
}
コード例 #17
0
ファイル: File.cpp プロジェクト: newmind/tvnc_rds
bool File::isDirectory() const
{
  WIN32_FIND_DATA fileInfo;
  if (getFileInfo(&fileInfo)) {
    if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
      return true;
    } 
  } 
  return false;
}
コード例 #18
0
ファイル: LocalFileLoader.cpp プロジェクト: Orphis/ppsspp
bool LocalFileLoader::Exists() {
	// If we couldn't open it for reading, we say it does not exist.
#ifndef _WIN32
	if (fd_ != -1 || IsDirectory()) {
#else
	if (handle_ != INVALID_HANDLE_VALUE || IsDirectory()) {
#endif
		FileInfo info;
		return getFileInfo(filename_.c_str(), &info);
	}
	return false;
}

bool LocalFileLoader::IsDirectory() {
	FileInfo info;
	if (getFileInfo(filename_.c_str(), &info)) {
		return info.isDirectory;
	}
	return false;
}
コード例 #19
0
ファイル: OsDirLinux.cpp プロジェクト: mranga/sipxecs
UtlBoolean OsDirLinux::exists()
{
    UtlBoolean stat = FALSE;

    OsFileInfoLinux info;
    OsStatus retval = getFileInfo(info);
    if (retval == OS_SUCCESS)
        stat = TRUE;

    return stat;
}
コード例 #20
0
ファイル: File.cpp プロジェクト: newmind/tvnc_rds
UINT64 File::lastModified() const
{
  WIN32_FIND_DATA fileInfo;

  if (!getFileInfo(&fileInfo)) {
    return 0;
  }

  DateTime dt(fileInfo.ftLastWriteTime);

  return dt.getTime();
}
コード例 #21
0
ファイル: File.cpp プロジェクト: newmind/tvnc_rds
UINT64 File::length() const
{
  WIN32_FIND_DATA fileInfo;

  if (!getFileInfo(&fileInfo)) {
    return 0;
  }

  INT64 maxDWORDPlusOne = 1 + (INT64)MAXDWORD;

  return fileInfo.nFileSizeHigh * maxDWORDPlusOne + fileInfo.nFileSizeLow;
}
コード例 #22
0
ファイル: zip_read.cpp プロジェクト: PeterTh/native
bool DirectoryAssetReader::GetFileInfo(const char *path, FileInfo *info) 
{
	char new_path[256] = {0};
	// Check if it already contains the path
	if (strlen(path) > strlen(path_) && 0 == memcmp(path, path_, strlen(path_))) {
	}
	else {
		strcpy(new_path, path_);
	}
	strcat(new_path, path);
	return getFileInfo(new_path, info);	
}
コード例 #23
0
ファイル: image_manager.c プロジェクト: schod005/ClassWork
//prints out all of the images for the given directory
//spawns new threads for each new directory encountered
void *showimagesV1(void *arg1)
{
	//get argument
	char *dir = (char*)arg1;
	DIR *dp = opendir(dir);
	if(dp == NULL)
	{
		printf("Cannot open directory: %s\n", dir);
		return NULL;
	}

	//scan through everything in current directory
	struct dirent *entry;
	while((entry = readdir(dp)) != NULL)
	{
		//ignore . and .. directories
		if(strcmp(".",entry->d_name) == 0 ||strcmp("..",entry->d_name) == 0)
				{continue;}
		pthread_mutex_lock(&dirCountMutex);
		dirCount++;
		pthread_mutex_unlock(&dirCountMutex);
		//get full file name (with path) of current file
		char curName[strlen(dir) + strlen(entry->d_name) + 3];
		strcpy(curName, dir);
		strcat(curName, "/");
		strcat(curName, entry->d_name);
		
		//see if the entry is a directory by attempting to open it
		DIR *dp2 = opendir(curName);
		if(dp2 != NULL)
		{
			//entry is a directory
			closedir(dp2);		//close directory
			char* curDir = (char*)malloc(strlen(curName) + 1);	//malloc to avoid string deletion
			strcpy(curDir, curName);
			thread_creator(curDir);	//spawn new thread for the directory
		}
		else if(getFileExtension(entry->d_name) != NULL)	//file is not a directory, check extension
		{
			//get information about file
			pthread_mutex_lock(&FilePrinting);
			getFileInfo(curName);
			pthread_mutex_unlock(&FilePrinting);
			//printf("%s\n",curName);
			pthread_mutex_lock(&CountMutex);
			count++;
			pthread_mutex_unlock(&CountMutex);
		}
	}
	closedir(dp);	//close directory
	return NULL;
}
コード例 #24
0
ファイル: sndcut.c プロジェクト: CamiWilliams/C-Languages
int main(int argc, char* argv[])
{
    FILE* f;
    struct file input;
    int k;
    int lows[argc];
    int highs[argc];
    int high, low, numRanges = 0;

    input = getFileInfo("(standard input)", stdin);
    fclose(f);
    for(k = 1; k < argc; k++)
    {
        if(strncmp(argv[k], "-h", 2) == 0)
        {
            fprintf(stderr, "This program reads a sound file from the standard input stream and writes it to the standard output stream. It removes all samples specified as arguments. The arguments are written as low..high \n");
        }
        else
        {
            /*Looks for range*/
            if(sscanf(argv[k], "%d..%d", &low, &high) > 0)
            {
                if( low >= 0 && high <= input.samples)
                {
                    lows[numRanges] = low;
                    highs[numRanges] = high;
                    numRanges++;
                }
                else {
                    fprintf(stderr, "\nYou specified ranges outside of the file sample ranges\n");
                }
            }
        }
    }

    if(input.error == 0)
    {
        input = removeRange(lows, highs, numRanges, input);
        if(input.error == 5)
        {
            fprintf(stderr, "Error: Boundaries written incorrectly");
            printf("\n");
            return 0;
        }
    }
    if(input.type == 1)	{
        convert(input, stdout, 2);
    }
    else if(input.type == 2) {
        convert(input, stdout, 1);
    }
}
コード例 #25
0
bool getFileModificationTime(const String& path, time_t& result)
{
    BY_HANDLE_FILE_INFORMATION fileInformation;
    if (!getFileInfo(path, fileInformation))
        return false;

    ULARGE_INTEGER t;
    memcpy(&t, &fileInformation.ftLastWriteTime, sizeof(t));
    
    result = t.QuadPart * 0.0000001 - 11644473600.0;

    return true;
}
コード例 #26
0
bool getFileSize(const String& path, long long& result)
{
    BY_HANDLE_FILE_INFORMATION fileInformation;
    if (!getFileInfo(path, fileInformation))
        return false;

    ULARGE_INTEGER fileSize;
    fileSize.LowPart = fileInformation.nFileSizeLow;
    fileSize.HighPart = fileInformation.nFileSizeHigh;

    result = fileSize.QuadPart;

    return true;
}
コード例 #27
0
ファイル: QtHost.cpp プロジェクト: lavo27/ppsspp
void TakeScreenshot() {
	g_TakeScreenshot = false;
	mkDir(g_Config.memCardDirectory + "/PSP/SCREENSHOT");

	// First, find a free filename.
	int i = 0;

	char temp[256];
	while (i < 10000){
		if(g_Config.bScreenshotsAsPNG)
			sprintf(temp, "%s/PSP/SCREENSHOT/screen%05d.png", g_Config.memCardDirectory.c_str(), i);
		else
			sprintf(temp, "%s/PSP/SCREENSHOT/screen%05d.jpg", g_Config.memCardDirectory.c_str(), i);
		FileInfo info;
		if (!getFileInfo(temp, &info))
			break;
		i++;
	}

	// Okay, allocate a buffer.
	u8 *buffer = new u8[3 * pixel_xres * pixel_yres];
	// Silly openGL reads upside down, we flip to another buffer for simplicity.
	u8 *flipbuffer = new u8[3 * pixel_xres * pixel_yres];

	glReadPixels(0, 0, pixel_xres, pixel_yres, GL_RGB, GL_UNSIGNED_BYTE, buffer);

	for (int y = 0; y < pixel_yres; y++) {
		memcpy(flipbuffer + y * pixel_xres * 3, buffer + (pixel_yres - y - 1) * pixel_xres * 3, pixel_xres * 3);
	}

	if (g_Config.bScreenshotsAsPNG) {
		png_image png;
		memset(&png, 0, sizeof(png));
		png.version = PNG_IMAGE_VERSION;
		png.format = PNG_FORMAT_RGB;
		png.width = pixel_xres;
		png.height = pixel_yres;
		png_image_write_to_file(&png, temp, 0, flipbuffer, pixel_xres * 3, NULL);
		png_image_free(&png);
	} else {
		jpge::params params;
		params.m_quality = 90;
		compress_image_to_jpeg_file(temp, pixel_xres, pixel_yres, 3, flipbuffer, params);
	}

	delete [] buffer;
	delete [] flipbuffer;

	osm.Show(temp);
}
コード例 #28
0
void FileSystemAssetBrowserModel::populateFolderContents(const IItem* item)
{
	impl_->folderContents_.clear();
	if (item)
	{
		auto folderItem = dynamic_cast<const BaseAssetObjectItem*>(item);
		if (folderItem)
		{
			std::vector<std::string> paths;
			auto fileInfo = folderItem->getFileInfo();
			paths.push_back(fileInfo->fullPath());
			addFolderItems(paths);
		}
	}
}
コード例 #29
0
ファイル: GameInfoCache.cpp プロジェクト: BlueSplash/ppsspp
static int64_t GetDirectoryRecursiveSize(std::string path) {
	std::vector<FileInfo> fileInfo;
	getFilesInDir(path.c_str(), &fileInfo);
	int64_t sizeSum = 0;
	// Note: getFileInDir does not fill in fileSize properly.
	for (size_t i = 0; i < fileInfo.size(); i++) {
		FileInfo finfo;
		getFileInfo(fileInfo[i].fullName.c_str(), &finfo);
		if (!finfo.isDirectory)
			sizeSum += finfo.size;
		else
			sizeSum += GetDirectoryRecursiveSize(finfo.fullName);
	}
	return sizeSum;
}
コード例 #30
0
	//------------------------------
	BitmapTex* MaterialCreator::createTexture( const COLLADAFW::EffectCommon& effectCommon, const COLLADAFW::Texture& texture )
	{
		BitmapTex* bitmapTexture = NewDefaultBitmapTex();
		COLLADAFW::SamplerID samplerId = texture.getSamplerId();
		const COLLADAFW::Sampler* sampler = effectCommon.getSamplerPointerArray()[ samplerId ];

		const COLLADAFW::UniqueId& imageUniqueId = sampler->getSourceImage();
		const COLLADAFW::Image* image = getFWImageByUniqueId( imageUniqueId );

		if ( !image )
			return 0;

		COLLADABU::URI imageUri( getFileInfo().absoluteFileUri, image->getImageURI().getURIString() );
		COLLADABU::NativeString imageFileName( imageUri.toNativePath().c_str(), COLLADABU::NativeString::ENCODING_UTF8 );
		bitmapTexture->SetMapName(const_cast<char*>(imageFileName.c_str()));
		bitmapTexture->LoadMapFiles(0);

		UVGen* uvGen = bitmapTexture->GetTheUVGen();
		StdUVGen* stdUVGen = (StdUVGen*)uvGen;

		// reset all flags
		//stdUVGen->SetFlag(U_WRAP|V_WRAP, 1);
		//stdUVGen->SetFlag(U_MIRROR|V_MIRROR, 0);
		int tiling = 0;
		
		if ( sampler->getWrapS() == COLLADAFW::Sampler::WRAP_MODE_WRAP )
		{
			tiling += 1<<0;
		}
		else if ( sampler->getWrapS() == COLLADAFW::Sampler::WRAP_MODE_MIRROR )
		{
			tiling += 1<<2;
		}

		if ( sampler->getWrapT() == COLLADAFW::Sampler::WRAP_MODE_WRAP )
		{
			tiling += 1<<1;
		}
		else if ( sampler->getWrapT() == COLLADAFW::Sampler::WRAP_MODE_MIRROR )
		{
			tiling += 1<<3;
		}

		stdUVGen->SetTextureTiling(tiling);


		return bitmapTexture;
	}