-
Notifications
You must be signed in to change notification settings - Fork 72
/
File.h
82 lines (68 loc) · 2.24 KB
/
File.h
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
74
75
76
77
78
79
80
81
82
/**
* This file is part of Pandion.
*
* Pandion is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pandion is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Pandion. If not, see <http://www.gnu.org/licenses/>.
*
* Filename: File.h
* Author(s): Dries Staelens
* Copyright: Copyright (c) 2009 Dries Staelens
* Description: This file declares a COM class that offers the agent
* facilities for creating, editing and deleting files.
*/
#pragma once
#include "DispInterfaceImpl.h"
/*
* This COM class provides the agent with facilities for creating, editing
* deleting files.
*/
class CFile :
public DispInterfaceImpl<IPdnFile>
{
private:
HANDLE m_FileHandle;
_bstr_t m_FileName;
BOOL m_HasWriteAccess;
BOOL m_AtEnd;
LPBYTE m_DataBuffer;
LPBYTE m_CurrentPosition;
public:
CFile();
virtual ~CFile();
void OnFinalRelease();
HRESULT GetWriteAccess();
STDMETHOD(Create)(BSTR strFileName, unsigned dwAccess, unsigned dwShare,
unsigned dwDisposition);
STDMETHOD(Seek)(int fpLow, int fpHigh, unsigned dwMethod);
STDMETHOD(SetEOF)();
STDMETHOD(Read)(unsigned nRead, BYTE* pBuffer);
STDMETHOD(Write)(BYTE* pBuffer, unsigned nWrite);
STDMETHOD(ReadLine)(BSTR* strLine);
STDMETHOD(WriteLine)(BSTR strLine);
STDMETHOD(ReadBase64)(BSTR* strBase64);
STDMETHOD(WriteBase64)(BSTR strBase64);
STDMETHOD(get_AtEnd)(BOOL* bAtEnd);
STDMETHOD(get_Size)(DWORD* nSize);
STDMETHOD(get_FileName)(BSTR* strFileName);
STDMETHOD(get_SHA1)(BSTR* strSHA1);
STDMETHOD(Move)(BSTR strTo);
STDMETHOD(Copy)(BSTR strTo, BOOL bOverWrite, IPdnFile** retCopy);
STDMETHOD(Delete)();
STDMETHOD(Flush)();
STDMETHOD(Close)();
STDMETHOD(get_LastWriteTime)(VARIANT* vLastWriteTime);
private:
void fixSlashes(_bstr_t &str);
_bstr_t getTempFileName();
void createFileDirectory(_bstr_t &str);
};