-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInputFile.C
More file actions
73 lines (65 loc) · 1.27 KB
/
InputFile.C
File metadata and controls
73 lines (65 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "secdel.H"
// CONSTRUCTOR: Sets filename string
InputFile::InputFile(LPCTSTR stringIn)
{
filename = stringIn;
}
// Opens the file from string
void InputFile::open()
{
hInput = CreateFile(
filename,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
}
// Resets the file pointer to 0
DWORD InputFile::resetHandle()
{
return SetFilePointer(
hInput,
0,
NULL,
FILE_BEGIN
);
}
// Returns size of input file
__int64 InputFile::filesize()
{
LO32 = GetFileSize (hInput, &HI32);
return (__int64)HI32 + (__int64)LO32;
}
// Writes to the file
bool InputFile::write(BYTE *byteArr, __int64 bytecount)
{
return WriteFile(
hInput,
byteArr,
bytecount,
&byteswritten,
NULL
);
}
// Renames the file
bool InputFile::rename(LPCTSTR currentname, LPCTSTR newname)
{
return MoveFileEx(
currentname,
newname,
MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH
);
}
// CLoses the handle to the InputFile
void InputFile::close()
{
CloseHandle(hInput);
}
// Deletes the file
bool InputFile::remove(LPCTSTR currentname)
{
return DeleteFile(currentname);
}