summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2012-04-25 18:16:45 +0200
committerTomas Bzatek <tbzatek@redhat.com>2012-04-25 18:16:45 +0200
commit8720dc62672508da0ae134f0f9599a4b3ed109fc (patch)
treed0306d8bf195d4db5088292508dda2065750e4f4
parentb2e39fd6de0767f35d4f9be34094706fd51d9513 (diff)
downloadtuxcmd-8720dc62672508da0ae134f0f9599a4b3ed109fc.tar.xz
Handle unstat-able entries in directory listing
A typical example is crashed fuse mount, leaving its mountpoint in an incosistent state.
-rw-r--r--UEngines.pas41
1 files changed, 40 insertions, 1 deletions
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;