Dennis Syrovatsky | 265d3c8 | 2006-04-17 12:36:11 +0000 | [diff] [blame] | 1 | /* 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 | *
|
| 20 | * TightVNC distribution homepage on the Web: http://www.tightvnc.com/
|
| 21 | *
|
| 22 | */
|
| 23 |
|
| 24 | // -=- SFileTransferWin32.cxx
|
| 25 |
|
| 26 | #include <rfb/msgTypes.h>
|
| 27 | #include <rfb_win32/FolderManager.h>
|
| 28 | #include <rfb_win32/SFileTransferWin32.h>
|
| 29 |
|
| 30 | using namespace rfb;
|
| 31 | using namespace rfb::win32;
|
| 32 |
|
| 33 | SFileTransferWin32::SFileTransferWin32(network::Socket *sock) : SFileTransfer(sock)
|
| 34 | {
|
| 35 | }
|
| 36 |
|
| 37 | SFileTransferWin32::~SFileTransferWin32()
|
| 38 | {
|
| 39 | }
|
| 40 |
|
| 41 | bool
|
| 42 | SFileTransferWin32::initDownloadCallback()
|
| 43 | {
|
| 44 | PostThreadMessage(GetCurrentThreadId(), VNCM_FT_DOWNLOAD, (WPARAM) 0, (LPARAM) this);
|
| 45 | return true;
|
| 46 | }
|
| 47 |
|
| 48 | bool
|
| 49 | SFileTransferWin32::processDownloadCallback()
|
| 50 | {
|
| 51 | return sendFileDownloadPortion();
|
| 52 | }
|
| 53 |
|
| 54 | bool
|
| 55 | SFileTransferWin32::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 |
|
| 76 | bool
|
| 77 | SFileTransferWin32::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 |
|
| 86 | bool
|
| 87 | SFileTransferWin32::deleteIt(char *pszPath)
|
| 88 | {
|
| 89 | FolderManager fm;
|
| 90 |
|
| 91 | return fm.deleteIt(pszPath);
|
| 92 | }
|
| 93 |
|
| 94 | bool
|
| 95 | SFileTransferWin32::renameIt(char *pszOldPath, char *pszNewPath)
|
| 96 | {
|
| 97 | FolderManager fm;
|
| 98 |
|
| 99 | return fm.renameIt(pszOldPath, pszNewPath);
|
| 100 | }
|
| 101 |
|
| 102 | bool
|
| 103 | SFileTransferWin32::createDir(char *pszPath)
|
| 104 | {
|
| 105 | FolderManager fm;
|
| 106 |
|
| 107 | return fm.createDir(pszPath);
|
| 108 | }
|
| 109 |
|
| 110 | bool
|
| 111 | SFileTransferWin32::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 |
|
| 119 | if (dw64DirSize & 0xFFFF000000000000) return false;
|
| 120 |
|
| 121 | *pHighSize16 = ((dw64DirSize & 0x0000FFFF00000000) >> 32);
|
| 122 | *pLowSize32 = (dw64DirSize & 0x00000000FFFFFFFF);
|
| 123 |
|
| 124 | return true;
|
| 125 | }
|