void FileTransferRequestHandler::mkDirRequested() { WinFilePath folderPath; { m_input->readUTF8(&folderPath); } // end of reading block. m_log->message(_T("mkdir \"%s\" command requested"), folderPath.getString()); checkAccess(); if (folderPath.parentPathIsRoot()) { throw FileTransferException(_T("Cannot create folder in root folder")); } File folder(folderPath.getString()); if (folder.exists()) { throw FileTransferException(_T("Directory already exists")); } if (!folder.mkdir()) { throw SystemException(); } { AutoLock l(m_output); m_output->writeUInt32(FTMessage::MKDIR_REPLY); m_output->flush(); } }
void FileTransferRequestHandler::uploadStartRequested() { // // Request input variables. // WinFilePath fullPathName; UINT8 uploadFlags; UINT64 initialOffset; { m_input->readUTF8(&fullPathName); uploadFlags = m_input->readUInt8(); initialOffset = m_input->readUInt64(); } m_log->message(_T("upload \"%s\" %d %d command requested"), fullPathName.getString(), uploadFlags, initialOffset); checkAccess(); // // Closing previous upload if it was broken // if (m_fileOutputStream != NULL) { delete m_fileOutputStream; m_fileOutputStream = 0; } if (m_uploadFile != NULL) { delete m_uploadFile; m_uploadFile = 0; } if (fullPathName.parentPathIsRoot()) { throw FileTransferException(_T("Cannot upload file to root folder")); } m_uploadFile = new File(fullPathName.getString()); // // Trying to create file or overwrite existing // if ((uploadFlags & 0x1) && (!m_uploadFile->truncate())) { throw SystemException(); } // // Trying to open file and seek to initial file position // m_fileOutputStream = new WinFileChannel(fullPathName.getString(), F_WRITE, FM_OPEN); m_fileOutputStream->seek(initialOffset); // // Send reply // { AutoLock l(m_output); m_output->writeUInt32(FTMessage::UPLOAD_START_REPLY); m_output->flush(); } } // void