MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / GetDir

Method GetDir

src/FTPClientWrapperSSL.cpp:101–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101int FTPClientWrapperSSL::GetDir(const char * path, FTPFile** files) {
102 int retcode = 0;
103 CUT_DIRINFO di;
104 FTPFile * ftpfiles;
105
106 //store original directory
107 //commented out: Cwd is not used in NppFTP at the moment
108 //char curpath[MAX_PATH];
109 //retcode = m_client.GetCurDir(curpath, MAX_PATH);
110 //if (retcode != UTE_SUCCESS)
111 // return OnReturn(-1);
112
113 // change the current working directory to the one specified
114 retcode = m_client.ChDir(path);
115 if (retcode != UTE_SUCCESS)
116 return OnReturn(-1);
117
118 if (strlen(m_ftpListParams) > 0)
119 retcode = m_client.GetDirInfo(m_ftpListParams);//path);
120 else
121 retcode = m_client.GetDirInfo();//path);
122
123 //return to original directory
124 //commented out: Cwd is not used in NppFTP at the moment
125 //m_client.ChDir(curpath);
126
127 if (retcode != UTE_SUCCESS) {
128 return OnReturn(-1);
129 }
130
131 bool endslash = path[strlen(path)-1] == '/';
132
133 if (retcode != UTE_SUCCESS)
134 {
135 return OnReturn(-1);
136 }
137
138 int count = m_client.GetDirInfoCount();
139
140 std::vector<FTPFile> vfiles;
141
142 for(int i = 0; i < count; i++) {
143 m_client.GetDirEntry(i,&di);
144
145 if (!lstrcmp(TEXT("."), di.fileName) || !lstrcmp(TEXT(".."), di.fileName))
146 continue;
147
148 FTPFile ftpfile{};
149
150 ftpfile.filePath[0] = 0;
151
152 char * utf8name = SU::TCharToUtf8(di.fileName);
153 char nameCpy[MAX_PATH+1]; //buffer used to handle symlinks
154
155 strncpy(nameCpy, utf8name, MAX_PATH);
156 nameCpy[MAX_PATH] = '\0';
157 SU::FreeChar(utf8name);
158

Callers 1

PerformMethod · 0.45

Calls 5

ChDirMethod · 0.80
GetDirInfoMethod · 0.80
GetDirInfoCountMethod · 0.80
GetDirEntryMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected