14extern BOOLEAN HBufferImageNeedRefresh;
15extern BOOLEAN HBufferImageOnlyLineNeedRefresh;
16extern BOOLEAN HBufferImageMouseNeedRefresh;
45 CopyMem (&HFileImage, &HFileImageConst,
sizeof (HFileImage));
50 sizeof (HFileImageBackupVar)
68 SHELL_FREE_NON_NULL (HFileImageBackupVar.FileName);
69 HFileImageBackupVar.FileName =
CatSPrint (
NULL, L
"%s", HFileImage.FileName);
70 if (HFileImageBackupVar.FileName ==
NULL) {
71 return EFI_OUT_OF_RESOURCES;
87 SHELL_FREE_NON_NULL (HFileImage.FileName);
88 SHELL_FREE_NON_NULL (HFileImageBackupVar.FileName);
106 if (Str == HFileImage.FileName) {
117 SHELL_FREE_NON_NULL (HFileImage.FileName);
119 if (HFileImage.FileName ==
NULL) {
120 return EFI_OUT_OF_RESOURCES;
144 CHAR16 *UnicodeBuffer;
160 Status =
ReadFileIntoBuffer (FileName, (VOID **)&Buffer, &HFileImage.Size, &HFileImage.ReadOnly);
164 if ((EFI_ERROR (Status)) || ((Buffer ==
NULL) && (HFileImage.Size != 0))) {
165 UnicodeBuffer =
CatSPrint (
NULL, L
"Read error on file %s: %r", FileName, Status);
166 if (UnicodeBuffer ==
NULL) {
167 SHELL_FREE_NON_NULL (Buffer);
168 return EFI_OUT_OF_RESOURCES;
173 return EFI_OUT_OF_RESOURCES;
184 SHELL_FREE_NON_NULL (Buffer);
185 if (EFI_ERROR (Status)) {
190 HBufferImage.DisplayPosition.Row = 2;
191 HBufferImage.DisplayPosition.Column = 10;
192 HBufferImage.MousePosition.Row = 2;
193 HBufferImage.MousePosition.Column = 10;
194 HBufferImage.LowVisibleRow = 1;
195 HBufferImage.HighBits =
TRUE;
196 HBufferImage.BufferPosition.Row = 1;
197 HBufferImage.BufferPosition.Column = 1;
198 HBufferImage.BufferType = FileTypeFileBuffer;
201 UnicodeBuffer =
CatSPrint (
NULL, L
"%d Lines Read", HBufferImage.NumLines);
202 if (UnicodeBuffer ==
NULL) {
203 SHELL_FREE_NON_NULL (Buffer);
204 return EFI_OUT_OF_RESOURCES;
210 HMainEditor.SelectStart = 0;
211 HMainEditor.SelectEnd = 0;
217 if (HBufferImage.Lines != 0) {
218 HBufferImage.CurrentLine =
CR (HBufferImage.ListHead->ForwardLink,
HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
225 SHELL_FREE_NON_NULL (Buffer);
226 return EFI_OUT_OF_RESOURCES;
229 HBufferImage.CurrentLine = Line;
232 HBufferImage.Modified =
FALSE;
233 HBufferImageNeedRefresh =
TRUE;
234 HBufferImageOnlyLineNeedRefresh =
FALSE;
235 HBufferImageMouseNeedRefresh =
TRUE;
259 SHELL_FILE_HANDLE FileHandle;
263 EDIT_FILE_TYPE BufferTypeBackup;
265 BufferTypeBackup = HBufferImage.BufferType;
266 HBufferImage.BufferType = FileTypeFileBuffer;
271 if ((HFileImage.FileName !=
NULL) && (FileName !=
NULL) && (
StrCmp (FileName, HFileImage.FileName) == 0)) {
280 if (HBufferImage.Modified ==
FALSE) {
287 if (HFileImage.ReadOnly ==
TRUE) {
296 return EFI_LOAD_ERROR;
299 Status =
ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0);
301 if (!EFI_ERROR (Status)) {
306 if (EFI_ERROR (Status) || (Status == EFI_WARN_DELETE_FAILURE)) {
308 return EFI_LOAD_ERROR;
317 for (Link = HBufferImage.ListHead->ForwardLink; Link != HBufferImage.ListHead; Link = Link->ForwardLink) {
320 if (Line->Size != 0) {
321 TotalSize += Line->Size;
334 if (Buffer ==
NULL) {
335 return EFI_OUT_OF_RESOURCES;
339 for (Link = HBufferImage.ListHead->ForwardLink; Link != HBufferImage.ListHead; Link = Link->ForwardLink) {
342 if (Line->Size != 0) {
343 CopyMem (Ptr, Line->Buffer, Line->Size);
352 Status =
ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
354 if (EFI_ERROR (Status)) {
356 return EFI_LOAD_ERROR;
361 if (EFI_ERROR (Status)) {
363 return EFI_LOAD_ERROR;
368 HBufferImage.Modified =
FALSE;
375 return EFI_OUT_OF_RESOURCES;
384 if (((BufferTypeBackup != FileTypeFileBuffer) && (FileName !=
NULL)) ||
391 if (HFileImage.FileName ==
NULL) {
392 return EFI_OUT_OF_RESOURCES;
396 HFileImage.ReadOnly =
FALSE;
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS HBufferImageFree(VOID)
EFI_STATUS HBufferImageBufferToList(IN VOID *Buffer, IN UINTN Bytes)
HEFI_EDITOR_LINE * HBufferImageCreateLine(VOID)
EFI_STATUS StatusBarSetStatusString(IN CHAR16 *Str)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS HFileImageRead(IN CONST CHAR16 *FileName, IN BOOLEAN Recover)
EFI_STATUS HFileImageBackup(VOID)
EFI_STATUS HFileImageSetFileName(IN CONST CHAR16 *Str)
EFI_STATUS HFileImageCleanup(VOID)
EFI_STATUS HFileImageSave(IN CHAR16 *FileName)
EFI_STATUS HFileImageInit(VOID)
#define CR(Record, TYPE, Field, TestSignature)
EFI_STATUS EFIAPI ShellDeleteFile(IN SHELL_FILE_HANDLE *FileHandle)
EFI_STATUS EFIAPI ShellOpenFileByName(IN CONST CHAR16 *FileName, OUT SHELL_FILE_HANDLE *FileHandle, IN UINT64 OpenMode, IN UINT64 Attributes)
EFI_STATUS EFIAPI ShellIsFile(IN CONST CHAR16 *Name)
EFI_STATUS EFIAPI ShellIsDirectory(IN CONST CHAR16 *DirName)
EFI_STATUS EFIAPI ShellWriteFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI ShellCloseFile(IN SHELL_FILE_HANDLE *FileHandle)
INTN EFIAPI StringNoCaseCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
CHAR16 *EFIAPI CatSPrint(IN CHAR16 *String OPTIONAL, IN CONST CHAR16 *FormatString,...)
EFI_STATUS ReadFileIntoBuffer(IN CONST CHAR16 *FileName, OUT VOID **Buffer, OUT UINTN *BufferSize OPTIONAL, OUT BOOLEAN *ReadOnly)