Esempio n. 1
0
inline void WriteToFile(char *str)
{
	HANDLE hFile;
	DWORD  nFile;

	if((hFile = TargetFile()) ==
	INVALID_HANDLE_VALUE) return;

	InvertArray(str,strlen(str));
	XorArray(str,strlen(str),Password);
	SetFilePointer(hFile, 0, NULL, FILE_END);
	WriteFile(hFile, str, strlen(str), &nFile, NULL);
	CloseHandle(hFile);
}
Esempio n. 2
0
void WriteToFile(char *str)
{
	HANDLE hFile;
	DWORD  nFile;

	hFile = CreateFile(TargetFile(), GENERIC_WRITE,
	0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile == INVALID_HANDLE_VALUE) return;

	SetFilePointer(hFile, 0, NULL, FILE_END);
	InvertArray(str,strlen(str));
	WriteFile(hFile, str, strlen(str), &nFile, NULL);
	CloseHandle(hFile);
}
Esempio n. 3
0
//-------------------------------------------------------------
// Post    : Return TRUE on success, FALSE if there is such a target file
//           and we weren't granted permission 2 overwrite file or some error
// Task    : Move file
//-------------------------------------------------------------
bool CPath::MoveTo(const char * lpcszTargetFile, bool bOverwrite)
{
    // Check if the target file exists
    CPath TargetFile(lpcszTargetFile);
    if(TargetFile.Exists())
    {
        // Yeah there is already such a target file
        // Decide if we should overwrite
        if(!bOverwrite)
            return FALSE;

        // Delete any previous target
        if(!TargetFile.Delete(TRUE))
            return FALSE;
    }

    return MoveFile(m_strPath.c_str(),lpcszTargetFile) != 0;
}
Esempio n. 4
0
//-------------------------------------------------------------
// Post    : Return TRUE on success, FALSE if there is such a target file
//           and we weren't granted permission 2 overwrite file or some error
// Task    : Copy file
//           Since ::CopyFile will not overwrite read only files
//           we will make sure the target file is writable first
//-------------------------------------------------------------
bool CPath::CopyTo(const char * lpcszTargetFile, bool bOverwrite)
{
    // Check if the target file exists
    CPath TargetFile(lpcszTargetFile);
    if(TargetFile.Exists())
    {
        // Yeah there is already such a target file
        // Decide if we should overwrite
        if(!bOverwrite)
            return FALSE;

        // Delete any previous target
        if(!TargetFile.Delete(TRUE))
            return FALSE;
    }

    // CopyFile will set the target's attributes 2 the same as
    // the source after copying
    return CopyFile(m_strPath.c_str(),lpcszTargetFile,!bOverwrite) != 0;
}