Skip to content

Commit 01c4ad1

Browse files
committed
Feature requests:
[Enhancement] Display file info #73 [FEATURE] Show file attributes #297 Feature request: Show file sizes #356 based on work from https://github.com/ashkulz/NppFTP/tree/mkerost add tooltip to display file and directory infos as tooltip - last modified date - size - permissions in unix format
1 parent dcf1e64 commit 01c4ad1

12 files changed

Lines changed: 136 additions & 22 deletions

UTCP/include/ftp_c.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,32 @@ class CUT_WSDataClient : public CUT_WSClient
9999

100100
// directory infomation linked list - ascii fileName for internal use
101101
typedef struct CUT_DIRINFOATag{
102-
char fileName[MAX_PATH+1]; // file or directory name
103-
long fileSize; // size of directory or file in bytes
104-
int day; // the day digit of the file date
105-
int month; // the month digit of the file date
106-
int year; // the year digit of the file date
107-
int hour; // the hour digit of the file date
108-
int minute; // the minute digit of the file date
109-
int isDir; // flag if the entry is directory or a file
110-
int permissions; // file or directoy permissions
111-
CUT_DIRINFOATag * next; // next available entry
102+
char fileName[MAX_PATH + 1]{}; // file or directory name
103+
char mod[11]{}; // unix file mod text
104+
long fileSize = 0; // size of directory or file in bytes
105+
int day = 0; // the day digit of the file date
106+
int month = 0; // the month digit of the file date
107+
int year = 0; // the year digit of the file date
108+
int hour = 0; // the hour digit of the file date
109+
int minute = 0; // the minute digit of the file date
110+
int isDir = 0; // flag if the entry is directory or a file
111+
int permissions = 0; // file or directoy permissions
112+
CUT_DIRINFOATag * next = nullptr; // next available entry
112113
}CUT_DIRINFOA;
113114

114115
// _TCHAR for UI
115116
typedef struct CUT_DIRINFOTag{
116-
_TCHAR fileName[MAX_PATH+1]; // file or directory name
117-
long fileSize; // size of directory or file in bytes
118-
int day; // the day digit of the file date
119-
int month; // the month digit of the file date
120-
int year; // the year digit of the file date
121-
int hour; // the hour digit of the file date
122-
int minute; // the minute digit of the file date
123-
int isDir; // flag if the entry is directory or a file
124-
int permissions; // file or directoy permissions
125-
CUT_DIRINFOTag * next; // next available entry
117+
_TCHAR fileName[MAX_PATH+1]{}; // file or directory name
118+
_TCHAR mod[11]{}; // unix file mod text
119+
long fileSize = 0; // size of directory or file in bytes
120+
int day = 0; // the day digit of the file date
121+
int month = 0; // the month digit of the file date
122+
int year = 0; // the year digit of the file date
123+
int hour = 0; // the hour digit of the file date
124+
int minute = 0; // the minute digit of the file date
125+
int isDir = 0; // flag if the entry is directory or a file
126+
int permissions = 0; // file or directoy permissions
127+
CUT_DIRINFOTag * next = nullptr; // next available entry
126128
}CUT_DIRINFO;
127129

128130

UTCP/src/ftp_c.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,6 +2424,7 @@ int CUT_FTPClient::GetDirEntry(int index, CUT_DIRINFO *dirInfo) {
24242424
//also not explicitly requested via OPTS UTF8 ON, see https://tools.ietf.org/html/draft-ietf-ftpext-utf-8-option-00
24252425
//see also issue https://github.com/ashkulz/NppFTP/issues/55
24262426
CUT_Str::cvtcpy(dirInfo->fileName,MAX_PATH, di->fileName, CP_UTF8);
2427+
CUT_Str::cvtcpy(dirInfo->mod, sizeof(dirInfo->mod), di->mod, CP_UTF8);
24272428
dirInfo->fileSize = di->fileSize;
24282429
dirInfo->day = di->day;
24292430
dirInfo->month = di->month;
@@ -2974,6 +2975,7 @@ void CUT_FTPClient::GetInfoInUNIXFormat( CUT_DIRINFOA * di){
29742975
++ loop;
29752976
}
29762977

2978+
strncpy(di->mod, m_szBuf, sizeof(di->mod)-1);
29772979

29782980
//directory attrib
29792981
if(m_szBuf[0]=='d' || m_szBuf[0] =='D')

src/FTPClientWrapperSSH.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,16 @@ int FTPClientWrapperSSH::GetDir(const char * path, FTPFile** files) {
138138
break;
139139
}
140140

141+
file.permissions = sfile->permissions;
142+
if(file.permissions)
143+
{
144+
//file permissions are available in unix format
145+
strncpy(file.mod, sfile->longname, sizeof(file.mod)-1);
146+
}
147+
141148
vFiles.push_back(file);
142149
count++;
150+
sftp_attributes_free(sfile);
143151
}
144152

145153
if (m_aborting) {

src/FTPClientWrapperSSL.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,14 @@ int FTPClientWrapperSSL::GetDir(const char * path, FTPFile** files) {
205205
break;
206206
}
207207

208+
209+
char* utf8mod = SU::TCharToUtf8(di.mod);
210+
211+
strncpy(ftpfile.mod, utf8mod, sizeof(ftpfile.mod)-1);
212+
SU::FreeChar(utf8mod);
213+
214+
ftpfile.permissions = di.permissions;
215+
208216
vfiles.push_back(ftpfile);
209217
}
210218

src/FTPFile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum FTPFileType { FTPTypeFile, FTPTypeDir, FTPTypeLink };
2323

2424
struct FTPFile {
2525
char filePath[MAX_PATH+1]; // full path to file (name included)
26+
char mod[11]; // unix file permissions as text, e.g. -rw-------
2627
long fileSize; // size of directory or file in bytes
2728
FILETIME ctime;
2829
FILETIME mtime;

src/FileObject.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ FileObject::FileObject(const char* path, bool _isDir, bool _isLink) :
5252
m_ctime = ft;
5353
m_mtime = ft;
5454
m_atime = ft;
55+
56+
m_mod = nullptr;
5557
}
5658

5759
FileObject::FileObject(FTPFile * ftpfile) :
@@ -77,11 +79,14 @@ FileObject::FileObject(FTPFile * ftpfile) :
7779
m_ctime = ftpfile->ctime;
7880
m_mtime = ftpfile->mtime;
7981
m_atime = ftpfile->atime;
82+
83+
m_mod = SU::strdup(ftpfile->mod);
8084
}
8185

8286
FileObject::~FileObject() {
8387
RemoveAllChildren();
8488
SU::free(m_path);
89+
SU::free(m_mod);
8590
SU::FreeTChar(m_localName);
8691
}
8792

@@ -165,6 +170,11 @@ bool FileObject::isRoot() const
165170
return (strcmp(GetPath(), "/") == 0);
166171
}
167172

173+
bool FileObject::containsProfile() const
174+
{
175+
return false;
176+
}
177+
168178
const char* FileObject::GetName() const {
169179
return m_name;
170180
}
@@ -177,6 +187,10 @@ const char* FileObject::GetPath() const {
177187
return m_path;
178188
}
179189

190+
const char* FileObject::GetMod() const {
191+
return m_mod;
192+
}
193+
180194
int FileObject::SetRefresh(bool refresh) {
181195
m_needRefresh = refresh;
182196
return 0;

src/FileObject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ class FileObject {
4747
virtual bool isLink() const;
4848
virtual bool isDir() const;
4949
virtual bool isRoot() const;
50+
virtual bool containsProfile() const;
5051

5152
virtual const char* GetName() const;
5253
virtual const TCHAR* GetLocalName() const;
5354
virtual const char* GetPath() const;
55+
virtual const char* GetMod() const;
5456

5557
virtual int SetRefresh(bool refresh);
5658
virtual bool GetRefresh() const;
@@ -90,6 +92,8 @@ class FileObject {
9092
FILETIME m_ctime;
9193
FILETIME m_mtime;
9294
FILETIME m_atime;
95+
96+
char* m_mod;
9397
};
9498

9599
#endif //FILEOBJECT_H

src/Windows/FTPWindow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,11 @@ LRESULT FTPWindow::MessageProc(UINT uMsg, WPARAM wParam, LPARAM lParam) {
726726
FileObject* current = m_treeview.GetItemFileObject(tvitem.hItem);
727727
if (!current || current->isRoot()) result = TRUE;
728728
break; }
729+
case TVN_GETINFOTIP: {
730+
const NMTVGETINFOTIP & nmt = (NMTVGETINFOTIP) * (NMTVGETINFOTIP*)lParam;
731+
return m_treeview.OnToolTip(&nmt);
732+
break;
733+
}
729734
case TVN_SELCHANGED: {
730735
const NM_TREEVIEW & nmt = (NM_TREEVIEW) *(NM_TREEVIEW*)lParam;
731736
m_currentSelection = m_treeview.GetItemFileObject(nmt.itemNew.hItem);

src/Windows/ProfileObject.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ bool ProfileObject::isRoot() const
382382
return m_isRoot;
383383
}
384384

385+
bool ProfileObject::containsProfile() const
386+
{
387+
return true;
388+
}
389+
385390
const char* ProfileObject::GetName() const {
386391
size_t l = strlen(m_name) + strlen(".mlc") + 1;
387392
char* name = new char[l];
@@ -432,6 +437,11 @@ const char* ProfileObject::GetPath() const {
432437
return m_path;
433438
}
434439

440+
const char* ProfileObject::GetMod() const
441+
{
442+
return nullptr;
443+
}
444+
435445
bool ProfileObject::UpdatePath()
436446
{
437447
m_path = (char *)MkPath(GetParent()->GetPath(), m_name);

src/Windows/ProfileObject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ class ProfileObject : public FileObject {
5555
virtual bool isLink() const;
5656
virtual bool isDir() const;
5757
virtual bool isRoot() const;
58+
virtual bool containsProfile() const;
5859

5960
virtual const char* GetName() const;
6061
virtual int SetName(const char* newName);
6162
virtual FTPProfile* GetProfile() const;
6263
virtual const TCHAR* GetLocalName() const;
6364
virtual const char* GetPath() const;
65+
virtual const char* GetMod() const;
6466

6567
virtual bool UpdatePath();
6668
virtual void SetProfiles(vProfile* profiles);

0 commit comments

Comments
 (0)