blob: ad77bd091f232eb7dc9ab5d63fc25790795bb672 [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* Copyright (C) 2006 TightVNC Team. All Rights Reserved.
2 *
3 * Developed by Dennis Syrovatsky.
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 * USA.
19 *
Peter Åstrand7877cd62009-02-25 16:15:48 +000020 *
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000021 *
22 */
23
24// -=- SFileTransferWin32.cxx
25
26#include <rfb/msgTypes.h>
27#include <rfb_win32/FolderManager.h>
28#include <rfb_win32/SFileTransferWin32.h>
29
30using namespace rfb;
31using namespace rfb::win32;
32
33SFileTransferWin32::SFileTransferWin32(network::Socket *sock) : SFileTransfer(sock)
34{
35}
36
37SFileTransferWin32::~SFileTransferWin32()
38{
39}
40
41bool
42SFileTransferWin32::initDownloadCallback()
43{
44 PostThreadMessage(GetCurrentThreadId(), VNCM_FT_DOWNLOAD, (WPARAM) 0, (LPARAM) this);
45 return true;
46}
47
48bool
49SFileTransferWin32::processDownloadCallback()
50{
51 return sendFileDownloadPortion();
52}
53
54bool
55SFileTransferWin32::convertPathFromNet(char *pszPath)
56{
57 int len = strlen(pszPath);
58 if (pszPath[0] == '/') {
59 if (len == 1) {
60 pszPath[0] = '\0';
61 return true;
62 }
63 } else {
64 return false;
65 }
66
67 for(int i = 0; i < (len - 1); i++) {
68 if(pszPath[i+1] == '/') pszPath[i+1] = '\\';
69 pszPath[i] = pszPath[i+1];
70 }
71
72 pszPath[len-1] = '\0';
73 return true;
74}
75
76bool
77SFileTransferWin32::makeFileList(char *pszPath, FileInfo *pFI, bool bDirOnly)
78{
79 FolderManager fm;
80 if (fm.getDirInfo(pszPath, pFI, bDirOnly))
81 return true;
82 else
83 return false;
84}
85
86bool
87SFileTransferWin32::deleteIt(char *pszPath)
88{
89 FolderManager fm;
90
91 return fm.deleteIt(pszPath);
92}
93
94bool
95SFileTransferWin32::renameIt(char *pszOldPath, char *pszNewPath)
96{
97 FolderManager fm;
98
99 return fm.renameIt(pszOldPath, pszNewPath);
100}
101
102bool
103SFileTransferWin32::createDir(char *pszPath)
104{
105 FolderManager fm;
106
107 return fm.createDir(pszPath);
108}
109
110bool
111SFileTransferWin32::getDirSize(char *pszName, unsigned short *pHighSize16,
112 unsigned int *pLowSize32)
113{
114 FolderManager fm;
115 DWORD64 dw64DirSize = 0;
116
117 if (!fm.getDirSize(pszName, &dw64DirSize)) return false;
118
Peter Åstrand06eee262008-12-09 12:46:47 +0000119 if (dw64DirSize & 0xFFFF000000000000LL) return false;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000120
Constantin Kaplinskyf167ddb2006-09-06 09:24:42 +0000121 *pHighSize16 = (unsigned short)((dw64DirSize >> 32) & 0xFFFF);
122 *pLowSize32 = (unsigned int)(dw64DirSize & 0xFFFFFFFF);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000123
124 return true;
125}