/** @file
Main file for attrib shell level 2 function.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel2CommandsLib.h"
{L"-a", TypeFlag},
{L"+a", TypeFlag},
{L"-s", TypeFlag},
{L"+s", TypeFlag},
{L"-h", TypeFlag},
{L"+h", TypeFlag},
{L"-r", TypeFlag},
{L"+r", TypeFlag},
};
/**
Function for 'attrib' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
)
{
ListOfFiles = NULL;
ProblemParam = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
//
// parse the command line
//
} else {
}
} else {
//
// check for "-?"
//
} else {
FileAttributesToAdd = 0;
//
// apply or remove each flag
//
}
}
}
}
}
}
}
}
if (FileAttributesToRemove == 0 && FileAttributesToAdd == 0) {
//
// Do display as we have no attributes to change
//
for ( ParamNumberCount = 1
;
; ParamNumberCount++
){
// if we dont have anything left, move on...
break;
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, ParamNumberCount));
} else {
){
-1,
-1,
NULL,
);
}
ListOfFiles = NULL;
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_CLOSE_FAIL), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, ParamNumberCount));
}
} // for loop for handling wildcard filenames
} // for loop for printing out the info
} else if ((FileAttributesToRemove & FileAttributesToAdd) != 0) {
//
// fail as we have conflcting params.
//
} else {
//
// enumerate through all the files/directories and apply the attributes
//
for ( ParamNumberCount = 1
;
; ParamNumberCount++
){
// if we dont have anything left, move on...
//
// make sure we are not failing on the first one we do... if yes that's an error...
//
if (ParamNumberCount == 1) {
}
break;
}
//
// OpenFileByName / GetFileInfo / Change attributes / SetFileInfo / CloseFile / free memory
// for each file or directory on the line.
//
//
// Open the file(s)
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, ParamNumberCount));
} else {
){
//
// skip the directory traversing stuff...
//
continue;
}
//
// if we are removing Read-Only we need to do that alone
//
//
// SetFileInfo
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, ParamNumberCount));
}
}
//
// change the attribute
//
//
// SetFileInfo
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_AD), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, ParamNumberCount));
}
}
ListOfFiles = NULL;
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_CLOSE_FAIL), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, ParamNumberCount));
}
} // for loop for handling wildcard filenames
}
}
}
}
//
// free the command line package
//
//
// return the status
//
return (ShellStatus);
}