From 8720dc62672508da0ae134f0f9599a4b3ed109fc Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Wed, 25 Apr 2012 18:16:45 +0200 Subject: Handle unstat-able entries in directory listing A typical example is crashed fuse mount, leaving its mountpoint in an incosistent state. --- UEngines.pas | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/UEngines.pas b/UEngines.pas index 24eee1a..4891314 100644 --- a/UEngines.pas +++ b/UEngines.pas @@ -123,6 +123,7 @@ type private FPath: string; FBlockSize: guint32; + function CreateFakeFileInfo(const APath: string; AddFullPath: boolean): PDataItem; public constructor Create; destructor Destroy; override; @@ -261,7 +262,10 @@ begin if (Buf <> '.') and (Buf <> '..') and (strlen(Buf) > 0) and (AddDotFiles or (Buf[0] <> '.')) then begin - Item := GetFileInfo(IncludeTrailingPathDelimiter(APath) + string(Buf), FollowSymlinks, AddFullPath, @FError); + Item := GetFileInfo(IncludeTrailingPathDelimiter(APath) + string(Buf), FollowSymlinks, AddFullPath, nil); + // Ignore failed stats, let's display just a filename and bogus info + if Item = nil then + Item := CreateFakeFileInfo(IncludeTrailingPathDelimiter(APath) + string(Buf), AddFullPath); List.Add(Item); end; end; @@ -346,6 +350,41 @@ begin Result := Item; end; +function TLocalTreeEngine.CreateFakeFileInfo(const APath: string; AddFullPath: boolean): PDataItem; +var Item: PDataItem; +begin + Item := malloc(sizeof(TDataItem)); + memset(Item, 0, sizeof(TDataItem)); + Item^.UpDir := False; + Item^.LnkPointTo := nil; + Item^.Selected := False; + + if AddFullPath then Item^.FName := strdup(PChar(APath)) + else Item^.FName := strdup(PChar(ExtractFileName(APath))); + Item^.FDisplayName := StrToUTF8(Item^.FName); + + Item^.Mode := 0; + Item^.IsDotFile := (Length(ExtractFileName(APath)) > 0) and (ExtractFileName(APath)[1] = '.'); + Item^.IsExecutable := False; + Item^.IsDir := False; + Item^.IsLnk := False; + Item^.IsBlk := False; + Item^.IsChr := False; + Item^.IsFIFO := False; + Item^.IsSock := False; + Item^.mtime := 0; + Item^.atime := 0; + Item^.ctime := 0; + Item^.UID := geteuid; + Item^.GID := getegid; + Item^.Size := 0; + Item^.PackedSize := -1; + Item^.inode_no := 0; + + Result := Item; +end; + + function TLocalTreeEngine.ChangeDir(const NewPath: string; Error: PPGError): boolean; var APath: string; Handle : PDIR; -- cgit v1.2.3