lysip
Sep12-04, 09:09 AM
ok well im new to this fourm and from what ive looked at you guys should be proud. anyway to the point im trying to make a function that checks if a file exists or not and returns 0 or 1 acordingly. what i have so far
here is my file_exist.h the file that i get build errors in...
NTSTATUS
Xefile_exists(const OCHAR file_1[]) {
/************************************************** ****
* checks and sees if a file exists if not it returns *
* 0 if so it returns 1 *
************************************************** ****/
NTSTATUS status;
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
HANDLE file_1;
OCHAR RedirectionBuffer[MAX_LAUNCH_PATH + 1];
POSTR Delimiter;
InitializeObjectAttributes(&ObjectAttributes, file_1, OBJ_CASE_INSENSITIVE, NULL, NULL);
status = NtOpenFile(file_1, GENERIC_READ, &ObjectAttributes, &IoStatusBlock, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_NONALERT);
if (!NT_SUCCESS(status)) {
return 0;
} else {
return 1;
}
}
i took that part that opens the file from some orther sources i had as far as i know they should work. but the problem is when i pass a const into it as the file.
my const in my orther file is this as i define it
const OCHAR xb_xbdm_enabled[] = OTEXT("\\Device\\Harddisk0\\Partition1\\debug_monitor_ena bled.bleh");
then i use it like this useing the if statment
if (Xefile_exists(xb_xbdm_enabled) == 1)
when i try and build i get a few errors haveing to do with the const.
my errors are
file_exist.h(11) : error C2082: redefinition of formal parameter 'file_1'
file_exist.h(15) : error C4090: '=' : different 'const' qualifiers
file_exist.h(17) : error C4090: 'function' : different 'const' qualifiers
NMAKE : U1077: 'cl' : return code '0x2'
ive tried a few things but i cant seem to get it to build. if anybody could help that would be great. oh and if anybody teh windows api that would be realy great seening as im sure some of the stuff in my file_exist.h is useless. thanks
here is my file_exist.h the file that i get build errors in...
NTSTATUS
Xefile_exists(const OCHAR file_1[]) {
/************************************************** ****
* checks and sees if a file exists if not it returns *
* 0 if so it returns 1 *
************************************************** ****/
NTSTATUS status;
OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock;
HANDLE file_1;
OCHAR RedirectionBuffer[MAX_LAUNCH_PATH + 1];
POSTR Delimiter;
InitializeObjectAttributes(&ObjectAttributes, file_1, OBJ_CASE_INSENSITIVE, NULL, NULL);
status = NtOpenFile(file_1, GENERIC_READ, &ObjectAttributes, &IoStatusBlock, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_NONALERT);
if (!NT_SUCCESS(status)) {
return 0;
} else {
return 1;
}
}
i took that part that opens the file from some orther sources i had as far as i know they should work. but the problem is when i pass a const into it as the file.
my const in my orther file is this as i define it
const OCHAR xb_xbdm_enabled[] = OTEXT("\\Device\\Harddisk0\\Partition1\\debug_monitor_ena bled.bleh");
then i use it like this useing the if statment
if (Xefile_exists(xb_xbdm_enabled) == 1)
when i try and build i get a few errors haveing to do with the const.
my errors are
file_exist.h(11) : error C2082: redefinition of formal parameter 'file_1'
file_exist.h(15) : error C4090: '=' : different 'const' qualifiers
file_exist.h(17) : error C4090: 'function' : different 'const' qualifiers
NMAKE : U1077: 'cl' : return code '0x2'
ive tried a few things but i cant seem to get it to build. if anybody could help that would be great. oh and if anybody teh windows api that would be realy great seening as im sure some of the stuff in my file_exist.h is useless. thanks