示例#1
0
/**
  Set information about a file or a volume.

  @param[in]  This             A pointer to the EFI_FILE_PROTOCOL instance that
                               is the file handle the information is for.
  @param[in]  InformationType  The type identifier for the information being set :
                               EFI_FILE_INFO_ID or EFI_FILE_SYSTEM_INFO_ID or
                               EFI_FILE_SYSTEM_VOLUME_LABEL_ID
  @param[in]  BufferSize       The size, in bytes, of Buffer.
  @param[in]  Buffer           A pointer to the data buffer to write. The type of the
                               data inside the buffer is indicated by InformationType.

  @retval  EFI_SUCCESS            The information was set.
  @retval  EFI_UNSUPPORTED        The InformationType is not known.
  @retval  EFI_DEVICE_ERROR       The last issued semi-hosting operation failed.
  @retval  EFI_ACCESS_DENIED      An attempt is made to change the name of a file
                                  to a file that is already present.
  @retval  EFI_ACCESS_DENIED      An attempt is being made to change the
                                  EFI_FILE_DIRECTORY Attribute.
  @retval  EFI_ACCESS_DENIED      InformationType is EFI_FILE_INFO_ID and
                                  the file was opened in read-only mode and an
                                  attempt is being made to modify a field other
                                  than Attribute.
  @retval  EFI_WRITE_PROTECTED    An attempt is being made to modify a read-only
                                  attribute.
  @retval  EFI_BAD_BUFFER_SIZE    The size of the buffer is lower than that indicated by
                                  the data inside the buffer.
  @retval  EFI_OUT_OF_RESOURCES   A allocation needed to process the request failed.
  @retval  EFI_INVALID_PARAMETER  At least one of the parameters is invalid.

**/
EFIAPI
EFI_STATUS
BootMonFsSetInfo (
  IN EFI_FILE_PROTOCOL  *This,
  IN EFI_GUID           *InformationType,
  IN UINTN              BufferSize,
  IN VOID               *Buffer
  )
{
  BOOTMON_FS_FILE       *File;
  EFI_FILE_INFO         *Info;
  EFI_FILE_SYSTEM_INFO  *SystemInfo;

  if ((This == NULL)            ||
      (InformationType == NULL) ||
      (Buffer == NULL)             ) {
    return EFI_INVALID_PARAMETER;
  }

  File = BOOTMON_FS_FILE_FROM_FILE_THIS (This);
  if (File->Info == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
    Info = Buffer;
    if (Info->Size < (SIZE_OF_EFI_FILE_INFO + StrSize (Info->FileName))) {
      return EFI_INVALID_PARAMETER;
    }
    if (BufferSize < Info->Size) {
      return EFI_BAD_BUFFER_SIZE;
    }
    return (SetFileInfo (File->Instance, File, Info));
  }

  //
  // The only writable field in the other two information types
  // (i.e. EFI_FILE_SYSTEM_INFO and EFI_FILE_SYSTEM_VOLUME_LABEL) is the
  // filesystem volume label. This can be retrieved with GetInfo, but it is
  // hard-coded into this driver, not stored on media.
  //

  if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
    SystemInfo = Buffer;
    if (SystemInfo->Size <
        (SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (SystemInfo->VolumeLabel))) {
      return EFI_INVALID_PARAMETER;
    }
    if (BufferSize < SystemInfo->Size) {
      return EFI_BAD_BUFFER_SIZE;
    }
    return EFI_WRITE_PROTECTED;
  }

  if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
    return EFI_WRITE_PROTECTED;
  }

  return EFI_UNSUPPORTED;
}
示例#2
0
EFIAPI
EFI_STATUS
BootMonFsSetInfo (
  IN EFI_FILE_PROTOCOL  *This,
  IN EFI_GUID           *InformationType,
  IN UINTN              BufferSize,
  IN VOID               *Buffer
  )
{
  EFI_STATUS           Status;
  BOOTMON_FS_FILE     *File;
  BOOTMON_FS_INSTANCE *Instance;

  File = BOOTMON_FS_FILE_FROM_FILE_THIS (This);
  if (File == NULL) {
    return EFI_DEVICE_ERROR;
  }

  Instance = File->Instance;

  if (CompareGuid (InformationType, &gEfiFileInfoGuid) != 0) {
    Status = SetFileInfo (Instance, File, BufferSize, (EFI_FILE_INFO *) Buffer);
  } else {
    // The only writable field in the other two information types
    // (i.e. EFI_FILE_SYSTEM_INFO and EFI_FILE_SYSTEM_VOLUME_LABEL) is the
    // filesystem volume label. This can be retrieved with GetInfo, but it is
    // hard-coded into this driver, not stored on media.
    Status = EFI_UNSUPPORTED;
  }

  return Status;
}
示例#3
0
BOOL ShareMng::AddFileShare(ShareInfo *shareInfo, char *fname)
{
	for (int i=0; i < shareInfo->fileCnt; i++) {
		if (strcmp(fname, shareInfo->fileInfo[i]->Fname()) == 0)
			return	FALSE;
	}
	return	AddShareCore(shareInfo, SetFileInfo(fname));
}
示例#4
0
/**
  Set information about a file or a file system.

  @param[in]  This             A pointer to the EFI_FILE_PROTOCOL instance that
                               is the file handle the information is for.
  @param[in]  InformationType  The type identifier for the information being set :
                               EFI_FILE_INFO_ID or EFI_FILE_SYSTEM_INFO_ID or
                               EFI_FILE_SYSTEM_VOLUME_LABEL_ID
  @param[in]  BufferSize       The size, in bytes, of Buffer.
  @param[in]  Buffer           A pointer to the data buffer to write. The type of the
                               data inside the buffer is indicated by InformationType.

  @retval  EFI_SUCCESS            The information was set.
  @retval  EFI_UNSUPPORTED        The InformationType is not known.
  @retval  EFI_DEVICE_ERROR       The last issued semi-hosting operation failed.
  @retval  EFI_ACCESS_DENIED      An attempt is being made to change the
                                  EFI_FILE_DIRECTORY Attribute.
  @retval  EFI_ACCESS_DENIED      InformationType is EFI_FILE_INFO_ID and
                                  the file is a read-only file or has been
                                  opened in read-only mode and an attempt is
                                  being made to modify a field other than
                                  Attribute.
  @retval  EFI_ACCESS_DENIED      An attempt is made to change the name of a file
                                  to a file that is already present.
  @retval  EFI_WRITE_PROTECTED    An attempt is being made to modify a
                                  read-only attribute.
  @retval  EFI_BAD_BUFFER_SIZE    The size of the buffer is lower than that indicated by
                                  the data inside the buffer.
  @retval  EFI_OUT_OF_RESOURCES   An allocation needed to process the request failed.
  @retval  EFI_INVALID_PARAMETER  At least one of the parameters is invalid.

**/
EFI_STATUS
FileSetInfo (
  IN EFI_FILE  *This,
  IN EFI_GUID  *InformationType,
  IN UINTN     BufferSize,
  IN VOID      *Buffer
  )
{
  SEMIHOST_FCB          *Fcb;
  EFI_FILE_INFO         *Info;
  EFI_FILE_SYSTEM_INFO  *SystemInfo;
  CHAR16                *VolumeLabel;

  if ((This == NULL) || (InformationType == NULL) || (Buffer == NULL)) {
    return EFI_INVALID_PARAMETER;
  }

  Fcb = SEMIHOST_FCB_FROM_THIS (This);

  if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
    Info = Buffer;
    if (Info->Size < (SIZE_OF_EFI_FILE_INFO + StrSize (Info->FileName))) {
      return EFI_INVALID_PARAMETER;
    }
    if (BufferSize < Info->Size) {
      return EFI_BAD_BUFFER_SIZE;
    }
    return SetFileInfo (Fcb, Info);
  } else if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
    SystemInfo = Buffer;
    if (SystemInfo->Size <
        (SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (SystemInfo->VolumeLabel))) {
      return EFI_INVALID_PARAMETER;
    }
    if (BufferSize < SystemInfo->Size) {
      return EFI_BAD_BUFFER_SIZE;
    }
    Buffer = SystemInfo->VolumeLabel;

    if (StrSize (Buffer) > 0) {
      VolumeLabel = AllocateCopyPool (StrSize (Buffer), Buffer);
      if (VolumeLabel != NULL) {
        FreePool (mSemihostFsLabel);
        mSemihostFsLabel = VolumeLabel;
        return EFI_SUCCESS;
      } else {
        return EFI_OUT_OF_RESOURCES;
      }
    } else {
      return EFI_INVALID_PARAMETER;
    }
  } else if (!CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
    return EFI_UNSUPPORTED;
  } else {
    return EFI_UNSUPPORTED;
  }
}
示例#5
0
  CompressWorker(string inputFile, string outputFile, int width, int height)
    : CNCSFile(), imageWidth(width), imageHeight(height)
  {
    // Fill out the band information structure
    NCSFileBandInfo bandInfo[IMAGE_BANDS];
    bandInfo[0].nBits = 8;
    bandInfo[0].bSigned = FALSE;
    bandInfo[0].szDesc = "Red";

    bandInfo[1].nBits = 8;
    bandInfo[1].bSigned = FALSE;
    bandInfo[1].szDesc = "Green";

    bandInfo[2].nBits = 8;
    bandInfo[2].bSigned = FALSE;
    bandInfo[2].szDesc = "Blue";

//     bandInfo[3].nBits = 8;
//     bandInfo[3].bSigned = FALSE;
//     bandInfo[3].szDesc = "Alpha";

    // Fill out the file information structure
    NCSFileViewFileInfoEx fileInfo;
    fileInfo.nSizeX = width;
    fileInfo.nSizeY = height;
    fileInfo.nBands = IMAGE_BANDS;
    fileInfo.nCompressionRate = 20;
    fileInfo.eCellSizeUnits = ECW_CELL_UNITS_METERS;
    fileInfo.fCellIncrementX = 1000;
    fileInfo.fCellIncrementY = 1000;
    fileInfo.fOriginX = 0;
    fileInfo.fOriginY = 0;
    fileInfo.szDatum = "RAW";
    fileInfo.szProjection = "RAW";

    fileInfo.fCWRotationDegrees = 0;
    fileInfo.eColorSpace = NCSCS_sRGB;
    fileInfo.eCellType = NCSCT_UINT8;
    fileInfo.pBands = bandInfo;

    CNCSError error = SetFileInfo(fileInfo);    
    string errorMessage = error.GetErrorMessage();

    // Open file for output
    char* fileNameC = new char[1000];
    strncpy(fileNameC, outputFile.c_str(), 1000);
    NCSError errorCode = Open(fileNameC, false, true);
    if(errorCode != NCS_SUCCESS) {
      string errorMessage = string(FormatErrorText(errorCode));
      cout << "NCS: " << errorMessage << endl;
    }
    delete[] fileNameC;

    // Open the input file
    input = CreateFile(inputFile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    inputBuffer = new unsigned char[imageWidth * IMAGE_BANDS];
  }
	void SyncUnmountableManager::AddFiles (const AddFilesParams& params)
	{
		auto coll = Core::Instance ().GetLocalCollection ();

		const auto& format = params.TCParams_.FormatID_;

		auto syncer = params.Syncer_;
		for (const auto& file : params.Files_)
		{
			const auto trackId = coll->FindTrack (file);
			if (trackId < 0)
				continue;

			const auto trackNumber = coll->GetCollectionModel ()->
					GetTrackData (trackId, LocalCollectionModel::Role::TrackNumber).toInt ();
			const auto& trackTitle = coll->GetCollectionModel ()->
					GetTrackData (trackId, LocalCollectionModel::Role::TrackTitle).toString ();

			const auto album = coll->GetTrackAlbum (trackId);
			if (!album)
				continue;

			const auto& artists = coll->GetAlbumArtists (album->ID_);
			if (artists.isEmpty ())
				continue;

			const auto& artist = coll->GetArtist (artists.at (0));

			syncer->SetFileInfo (file,
					{
						format.isEmpty () ?
							QFileInfo (file).suffix ().toLower () :
							format,
						trackNumber,
						trackTitle,
						artist.Name_,
						album->Name_,
						album->Year_,
						album->CoverPath_,
						QStringList ()
					});

			Source2Params_ [file] = params;
		}

		SyncManagerBase::AddFiles (params.Files_, params.TCParams_);
	}
示例#7
0
int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
{
	pspParam = param;
	if (!pspParam)
	{
		Clear();
		return 0;
	}

	bool listEmptyFile = true;
	if (param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD ||
			param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTDELETE)
	{
		listEmptyFile = false;
	}

	char (*saveNameListData)[20];
	bool hasMultipleFileName = false;
	if (param->saveNameList != 0)
	{
		Clear();

		saveNameListData = (char(*)[20])Memory::GetPointer(param->saveNameList);

		// Get number of fileName in array
		saveDataListCount = 0;
		while(saveNameListData[saveDataListCount][0] != 0)
		{
			saveDataListCount++;
		}

		if(saveDataListCount > 0)
		{
			hasMultipleFileName = true;
			saveDataList = new SaveFileInfo[saveDataListCount];

			// get and stock file info for each file
			int realCount = 0;
			for (int i = 0; i < saveDataListCount; i++)
			{
				DEBUG_LOG(HLE,"Name : %s",saveNameListData[i]);

				std::string fileDataPath = savePath+GetGameName(param)+saveNameListData[i]+"/"+param->fileName;
				PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath);
				if (info.exists)
				{
					SetFileInfo(realCount, info, saveNameListData[i]);

					DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());
					realCount++;
				}
				else
				{
					if (listEmptyFile)
					{
						saveDataList[realCount].size = 0;
						saveDataList[realCount].saveName = saveNameListData[i];
						saveDataList[realCount].idx = i;
						saveDataList[realCount].textureData = 0;

						if(Memory::IsValidAddress(param->newData))
						{
							// We have a png to show
							PspUtilitySavedataFileData newData;
							Memory::ReadStruct(param->newData, &newData);
							CreatePNGIcon(Memory::GetPointer(newData.buf), (int)newData.size, saveDataList[realCount]);
						}
						DEBUG_LOG(HLE,"Don't Exist");
						realCount++;
					}
				}
			}
			saveNameListDataCount = realCount;
		}
	}
	if(!hasMultipleFileName) // Load info on only save
	{
		saveNameListData = 0;

		Clear();
		saveDataList = new SaveFileInfo[1];
		saveDataListCount = 1;

		// get and stock file info for each file
		DEBUG_LOG(HLE,"Name : %s",GetSaveName(param).c_str());

		std::string fileDataPath = savePath+GetGameName(param)+GetSaveName(param)+"/"+param->fileName;
		PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath);
		if (info.exists)
		{
			SetFileInfo(0, info, GetSaveName(pspParam));

			DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());
			saveNameListDataCount = 1;
		}
		else
		{
			if (listEmptyFile)
			{
				saveDataList[0].size = 0;
				saveDataList[0].saveName = GetSaveName(param);
				saveDataList[0].idx = 0;
				saveDataList[0].textureData = 0;

				if(Memory::IsValidAddress(param->newData))
				{
					// We have a png to show
					PspUtilitySavedataFileData newData;
					Memory::ReadStruct(param->newData, &newData);
					CreatePNGIcon(Memory::GetPointer(newData.buf), (int)newData.size, saveDataList[0]);
				}
				DEBUG_LOG(HLE,"Don't Exist");
			}
			saveNameListDataCount = 0;
			return 0;
		}
	}
	return 0;
}
示例#8
0
void SavedataParam::SetFileInfo(int idx, PSPFileInfo &info, std::string saveName)
{
	SetFileInfo(saveDataList[idx], info, saveName);
	saveDataList[idx].idx = idx;
}
示例#9
0
int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
{
	pspParam = param;
	if (!pspParam)
	{
		Clear();
		return 0;
	}

	bool listEmptyFile = true;
	if (param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD ||
			param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTDELETE)
	{
		listEmptyFile = false;
	}

	SceUtilitySavedataSaveName *saveNameListData;
	bool hasMultipleFileName = false;
	if (param->saveNameList.Valid())
	{
		Clear();

		saveNameListData = param->saveNameList;

		// Get number of fileName in array
		saveDataListCount = 0;
		while (saveNameListData[saveDataListCount][0] != 0)
		{
			saveDataListCount++;
		}

		if (saveDataListCount > 0)
		{
			hasMultipleFileName = true;
			saveDataList = new SaveFileInfo[saveDataListCount];

			// get and stock file info for each file
			int realCount = 0;
			for (int i = 0; i < saveDataListCount; i++)
			{
				// TODO: Maybe we should fill the list with existing files instead?
				if (strcmp(saveNameListData[i], "<>") == 0)
					continue;

				DEBUG_LOG(HLE,"Name : %s",saveNameListData[i]);

				std::string fileDataPath = savePath+GetGameName(param) + saveNameListData[i] + "/" + param->fileName;
				PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath);
				if (info.exists)
				{
					SetFileInfo(realCount, info, saveNameListData[i]);

					DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());
					realCount++;
				}
				else
				{
					if (listEmptyFile)
					{
						ClearFileInfo(saveDataList[realCount], saveNameListData[i]);
						DEBUG_LOG(HLE,"Don't Exist");
						realCount++;
					}
				}
			}
			saveNameListDataCount = realCount;
		}
	}
	if (!hasMultipleFileName) // Load info on only save
	{
		saveNameListData = 0;

		Clear();
		saveDataList = new SaveFileInfo[1];
		saveDataListCount = 1;

		// get and stock file info for each file
		DEBUG_LOG(HLE,"Name : %s",GetSaveName(param).c_str());

		std::string fileDataPath = savePath + GetGameName(param) + GetSaveName(param) + "/" + param->fileName;
		PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath);
		if (info.exists)
		{
			SetFileInfo(0, info, GetSaveName(param));

			DEBUG_LOG(HLE,"%s Exist",fileDataPath.c_str());
			saveNameListDataCount = 1;
		}
		else
		{
			if (listEmptyFile)
			{
				ClearFileInfo(saveDataList[0], GetSaveName(param));
				DEBUG_LOG(HLE,"Don't Exist");
			}
			saveNameListDataCount = 0;
			return 0;
		}
	}
	return 0;
}
示例#10
0
CNCSError ECWDEMCompressor::Compress(ImageFormatECWDEM *NewIFECW, RasterBounds *RBounds, char *pDstFile, UINT32 ImgWidth, UINT32 ImgHeight, char Depth, UINT16 nRate)
{
//NCSFileViewFileInfoEx has basic info about the file - dimensions, bands,
//georeferencing information etc.
    NCSFileViewFileInfoEx *pDstInfo = (NCSFileViewFileInfoEx *)NCSMalloc(sizeof(NCSFileViewFileInfoEx), true);
    NCSFileViewFileInfoEx DstInfo = *pDstInfo;
    CNCSError Error;

    IFECW = NewIFECW;
    DstInfo.nSizeX = ImgWidth;
    DstInfo.nSizeY = ImgHeight;
    switch (Depth)
    {
    case 8:
        DstInfo.eCellType = NCSCT_UINT8;
        break;
    case 16:
        DstInfo.eCellType = NCSCT_UINT16;
        break;
    //case 28: DstInfo.eCellType = NCSCT_IEEE4; break;
    case 28:
        DstInfo.eCellType = NCSCT_UINT32;
        break;
    } // switch

    DstInfo.nBands = 1;
    DstInfo.nCompressionRate = nRate;
    DstInfo.eColorSpace = NCSCS_GREYSCALE;

#ifdef WCS_BUILD_VNS
    if (RBounds && RBounds->FetchCoordSys())
    {
        IFECW->CreateECWGeoRefNewAPI(RBounds->FetchCoordSys(), &DstInfo, RBounds);
    } // if
#endif // WCS_BUILD_VNS

//DstInfo.szProjection = "RAW";
//DstInfo.szDatum = "RAW";
//DstInfo.eCellSizeUnits = ECW_CELL_UNITS_METERS;
//DstInfo.fCellIncrementX = 1.0;
//DstInfo.fCellIncrementY = 1.0;
//DstInfo.fOriginX = 0.0;
//DstInfo.fOriginY = 0.0;

    DstInfo.pBands = (NCSFileBandInfo *)(new NCSFileBandInfo[DstInfo.nBands]);
    DstInfo.pBands[0].nBits = Depth;
    DstInfo.pBands[0].bSigned = false;
    DstInfo.pBands[0].szDesc = "Elevation";

//Call SetFileInfo to establish the file information we are going to
//use for compression.  The parameters used are those from the NCSFileViewFileInfoEx
//struct we have populated using metadata derived from our input raster.
    Error = SetFileInfo(DstInfo);
    Error = Open(pDstFile, false, true);
    if (Error == NCS_SUCCESS)
    {
#ifdef WCS_BUILD_JP2BOX_SUPPORT
        JP2UUID3DNBox RangeEquivs(NewIFECW->HighElev, NewIFECW->LowElev, (unsigned long int)NewIFECW->MaxValue, 0);
        AddBox(&RangeEquivs);
#endif // WCS_BUILD_JP2BOX_SUPPORT

        Error = Write();
        if (Error == NCS_SUCCESS)
            fprintf(stdout,"Finished compression\n");
        else if (Error == NCS_USER_CANCELLED_COMPRESSION)
            fprintf(stdout,"Compression cancelled\n");
        else fprintf(stdout,"Error during compression: %s\n",Error.GetErrorMessage());

        Error = Close(true);
    } // if

    return(Error);

} // ECWDEMCompressor::Compress