1 #include "filezilla.h"
2
CConnectCommand(CServer const & server,ServerHandle const & handle,Credentials const & credentials,bool retry_connecting)3 CConnectCommand::CConnectCommand(CServer const& server, ServerHandle const& handle, Credentials const& credentials, bool retry_connecting)
4 : server_(server)
5 , handle_(handle)
6 , credentials_(credentials)
7 , retry_connecting_(retry_connecting)
8 {
9 }
10
valid() const11 bool CConnectCommand::valid() const
12 {
13 if (!server_) {
14 return false;
15 }
16 return true;
17 }
18
CListCommand(int flags)19 CListCommand::CListCommand(int flags)
20 : m_flags(flags)
21 {
22 }
23
CListCommand(CServerPath path,std::wstring const & subDir,int flags)24 CListCommand::CListCommand(CServerPath path, std::wstring const& subDir, int flags)
25 : m_path(path), m_subDir(subDir), m_flags(flags)
26 {
27 }
28
GetPath() const29 CServerPath CListCommand::GetPath() const
30 {
31 return m_path;
32 }
33
GetSubDir() const34 std::wstring CListCommand::GetSubDir() const
35 {
36 return m_subDir;
37 }
38
valid() const39 bool CListCommand::valid() const
40 {
41 if (GetPath().empty() && !GetSubDir().empty()) {
42 return false;
43 }
44
45 if (GetFlags() & LIST_FLAG_LINK && GetSubDir().empty()) {
46 return false;
47 }
48
49 bool const refresh = (m_flags & LIST_FLAG_REFRESH) != 0;
50 bool const avoid = (m_flags & LIST_FLAG_AVOID) != 0;
51 if (refresh && avoid) {
52 return false;
53 }
54
55 return true;
56 }
57
CFileTransferCommand(reader_factory_holder const & reader,CServerPath const & remotePath,std::wstring const & remoteFile,transfer_flags const & flags)58 CFileTransferCommand::CFileTransferCommand(reader_factory_holder const& reader, CServerPath const& remotePath,
59 std::wstring const& remoteFile, transfer_flags const& flags)
60 : reader_(reader), m_remotePath(remotePath), m_remoteFile(remoteFile)
61 , flags_(flags)
62 {
63 }
64
CFileTransferCommand(writer_factory_holder const & writer,CServerPath const & remotePath,std::wstring const & remoteFile,transfer_flags const & flags)65 CFileTransferCommand::CFileTransferCommand(writer_factory_holder const& writer, CServerPath const& remotePath,
66 std::wstring const& remoteFile, transfer_flags const& flags)
67 : writer_(writer), m_remotePath(remotePath), m_remoteFile(remoteFile)
68 , flags_(flags)
69 {
70 }
71
GetRemotePath() const72 CServerPath CFileTransferCommand::GetRemotePath() const
73 {
74 return m_remotePath;
75 }
76
GetRemoteFile() const77 std::wstring CFileTransferCommand::GetRemoteFile() const
78 {
79 return m_remoteFile;
80 }
81
valid() const82 bool CFileTransferCommand::valid() const
83 {
84 if (!reader_ && !writer_) {
85 return false;
86 }
87
88 if (m_remotePath.empty() || m_remoteFile.empty()) {
89 return false;
90 }
91
92 return true;
93 }
94
CRawCommand(std::wstring const & command)95 CRawCommand::CRawCommand(std::wstring const& command)
96 {
97 m_command = command;
98 }
99
GetCommand() const100 std::wstring CRawCommand::GetCommand() const
101 {
102 return m_command;
103 }
104
CDeleteCommand(const CServerPath & path,std::vector<std::wstring> && files)105 CDeleteCommand::CDeleteCommand(const CServerPath& path, std::vector<std::wstring>&& files)
106 : m_path(path), files_(files)
107 {
108 }
109
CRemoveDirCommand(const CServerPath & path,std::wstring const & subDir)110 CRemoveDirCommand::CRemoveDirCommand(const CServerPath& path, std::wstring const& subDir)
111 : m_path(path), m_subDir(subDir)
112 {
113 }
114
valid() const115 bool CRemoveDirCommand::valid() const
116 {
117 return !GetPath().empty() && !GetSubDir().empty();
118 }
119
CMkdirCommand(const CServerPath & path)120 CMkdirCommand::CMkdirCommand(const CServerPath& path)
121 : m_path(path)
122 {
123 }
124
valid() const125 bool CMkdirCommand::valid() const
126 {
127 return !GetPath().empty() && GetPath().HasParent();
128 }
129
CRenameCommand(CServerPath const & fromPath,std::wstring const & fromFile,CServerPath const & toPath,std::wstring const & toFile)130 CRenameCommand::CRenameCommand(CServerPath const& fromPath, std::wstring const& fromFile,
131 CServerPath const& toPath, std::wstring const& toFile)
132 : m_fromPath(fromPath)
133 , m_toPath(toPath)
134 , m_fromFile(fromFile)
135 , m_toFile(toFile)
136 {}
137
valid() const138 bool CRenameCommand::valid() const
139 {
140 return !GetFromPath().empty() && !GetToPath().empty() && !GetFromFile().empty() && !GetToFile().empty();
141 }
142
CChmodCommand(CServerPath const & path,std::wstring const & file,std::wstring const & permission)143 CChmodCommand::CChmodCommand(CServerPath const& path, std::wstring const& file, std::wstring const& permission)
144 : m_path(path)
145 , m_file(file)
146 , m_permission(permission)
147 {}
148
valid() const149 bool CChmodCommand::valid() const
150 {
151 return !GetPath().empty() && !GetFile().empty() && !GetPermission().empty();
152 }
153