descriptionwdx.lua 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. -- This script reads file descriptions from descript.ion
  2. function ContentGetSupportedField(Index)
  3. if (Index > 0) then
  4. return '','', 0; -- ft_nomorefields
  5. end
  6. return 'Description','', 8; -- FieldName,Units,ft_string
  7. end
  8. function ContentGetDefaultSortOrder(FieldIndex)
  9. return 1; --or -1
  10. end
  11. function ContentGetDetectString()
  12. return 'EXT="*"'; -- return detect string
  13. end
  14. function ContentGetValue(FileName, FieldIndex, UnitIndex, flags)
  15. if FieldIndex==0 then
  16. --Linux paths only
  17. local pat="/.*/"
  18. i,j=string.find(FileName,pat);
  19. if i~=nil then
  20. local path=string.sub(FileName,i,j);
  21. fn=string.sub(FileName,string.len(path)+1,-1);
  22. if fn~=".." then
  23. return GetDesc(path,fn);
  24. else
  25. return "";
  26. end
  27. end
  28. end
  29. return nil;
  30. end
  31. function GetDesc(Path,Name)
  32. local f=io.open(Path..'descript.ion',"r");
  33. if not f then
  34. return nil;
  35. end
  36. for line in f:lines() do
  37. if string.find(line,Name..' ') then
  38. f:close();
  39. return string.sub(line,string.len(Name..' ')+1,-1);
  40. end
  41. end
  42. f:close();
  43. return nil;
  44. end