Browse Source

Separating owner and group when parsing MLSx

Source commit: c08656c3a56119685913714dcebd59daec44c6bd
Martin Prikryl 9 years ago
parent
commit
75bba31989

+ 16 - 7
source/core/FtpFileSystem.cpp

@@ -4688,15 +4688,24 @@ bool __fastcall TFTPFileSystem::HandleListData(const wchar_t * Path,
 
         File->HumanRights = Entry->HumanPerm;
 
-        const wchar_t * Space = wcschr(Entry->OwnerGroup, L' ');
-        if (Space != NULL)
+        // deprecated, to be replaced with Owner/Group
+        if (wcslen(Entry->OwnerGroup) > 0)
         {
-          File->Owner.Name = UnicodeString(Entry->OwnerGroup, Space - Entry->OwnerGroup);
-          File->Group.Name = Space + 1;
+          const wchar_t * Space = wcschr(Entry->OwnerGroup, L' ');
+          if (Space != NULL)
+          {
+            File->Owner.Name = UnicodeString(Entry->OwnerGroup, Space - Entry->OwnerGroup);
+            File->Group.Name = Space + 1;
+          }
+          else
+          {
+            File->Owner.Name = Entry->OwnerGroup;
+          }
         }
         else
         {
-          File->Owner.Name = Entry->OwnerGroup;
+          File->Owner.Name = Entry->Owner;
+          File->Group.Name = Entry->Group;
         }
 
         File->Size = Entry->Size;
@@ -4729,8 +4738,8 @@ bool __fastcall TFTPFileSystem::HandleListData(const wchar_t * Path,
       {
         delete File;
         UnicodeString EntryData =
-          FORMAT(L"%s/%s/%s/%s/%s/%d/%d/%d/%d/%d/%d/%d/%d/%d/%d",
-            (Entry->Name, Entry->Permissions, Entry->HumanPerm, Entry->OwnerGroup, IntToStr(Entry->Size),
+          FORMAT(L"%s/%s/%s/%s/%s/%s/%s/%d/%d/%d/%d/%d/%d/%d/%d/%d/%d",
+            (Entry->Name, Entry->Permissions, Entry->HumanPerm, Entry->Owner, Entry->Group, Entry->OwnerGroup, IntToStr(Entry->Size),
              int(Entry->Dir), int(Entry->Link), Entry->Time.Year, Entry->Time.Month, Entry->Time.Day,
              Entry->Time.Hour, Entry->Time.Minute, int(Entry->Time.HasTime),
              int(Entry->Time.HasSeconds), int(Entry->Time.HasDate)));

+ 2 - 0
source/filezilla/FileZillaIntf.cpp

@@ -445,6 +445,8 @@ bool __fastcall TFileZillaIntf::HandleMessage(WPARAM wParam, LPARAM lParam)
           Dest.Permissions = Source.permissionstr;
           Dest.HumanPerm = Source.humanpermstr;
           Dest.OwnerGroup = Source.ownergroup;
+          Dest.Owner = Source.owner;
+          Dest.Group = Source.group;
           Dest.Size = Source.size;
           Dest.Dir = Source.dir;
           Dest.Link = Source.bLink;

+ 3 - 1
source/filezilla/FileZillaIntf.h

@@ -30,7 +30,9 @@ struct TListDataEntry
   const wchar_t * Name;
   const wchar_t * Permissions;
   const wchar_t * HumanPerm;
-  const wchar_t * OwnerGroup;
+  const wchar_t * OwnerGroup; // deprecated, to be replaced with Owner/Group
+  const wchar_t * Owner;
+  const wchar_t * Group;
   __int64 Size;
   bool Dir;
   bool Link;

+ 10 - 6
source/filezilla/FtpListResult.cpp

@@ -484,6 +484,8 @@ BOOL CFtpListResult::parseLine(const char *lineToParse, const int linelen, t_dir
 
   nFTPServerType = 0;
   direntry.ownergroup = L"";
+  direntry.owner = L"";
+  direntry.group = L"";
 
   if (parseAsMlsd(lineToParse, linelen, direntry, mlst))
     return TRUE;
@@ -1294,6 +1296,8 @@ BOOL CFtpListResult::parseAsMlsd(const char *line, const int linelen, t_director
   direntry.dir = FALSE;
   direntry.bLink = FALSE;
   direntry.ownergroup = L"";
+  direntry.owner = L"";
+  direntry.group = L"";
   direntry.permissionstr = L"";
 
   CString owner, group, uid, gid;
@@ -1422,16 +1426,16 @@ BOOL CFtpListResult::parseAsMlsd(const char *line, const int linelen, t_director
     facts = facts.Mid(delim + 1);
   }
 
-  // The order of the facts is undefined, so assemble ownerGroup in correct
-  // order
+  // The order of the facts is undefined
   if (!owner.IsEmpty())
-    direntry.ownergroup += owner;
+    direntry.owner = owner;
   else if (!uid.IsEmpty())
-    direntry.ownergroup += uid;
+    direntry.owner = uid;
+
   if (!group.IsEmpty())
-    direntry.ownergroup += L" " + group;
+    direntry.group = group;
   else if (!gid.IsEmpty())
-    direntry.ownergroup += L" " + gid;
+    direntry.group = gid;
 
   if (line[pos] != L' ')
   {

+ 3 - 1
source/filezilla/structures.h

@@ -21,7 +21,9 @@ public:
     CString name;
     CString permissionstr;
     CString humanpermstr; // RFC format
-    CString ownergroup;
+    CString ownergroup; // deprecated, to be replaced with owner/group
+    CString owner;
+    CString group;
     __int64 size;
     bool dir;
     bool bLink;