doc.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package filesystem // import "imuslab.com/arozos/mod/filesystem"
  2. FUNCTIONS
  3. func BufferedLargeFileCopy(src string, dst string, BUFFERSIZE int64) error
  4. Use for copying large file using buffering method. Allowing copying large
  5. file with little RAM
  6. func CheckMounted(mountpoint string) bool
  7. func DecodeURI(inputPath string) string
  8. func FileCopy(src string, dest string, mode string) error
  9. func FileMove(src string, dest string, mode string, fastMove bool) error
  10. func GetFileDisplaySize(filesize int64, rounding int) string
  11. func GetFileSize(filename string) int64
  12. func GetMime(filepath string) (string, string, error)
  13. func GetModTime(filepath string) (int64, error)
  14. func IsDir(path string) bool
  15. func MatchingFileSystem(fsa *FileSystemHandler, fsb *FileSystemHandler) bool
  16. Check if the two file system are identical.
  17. func MountDevice(mountpt string, mountdev string, filesystem string) error
  18. func ViewZipFile(filepath string) ([]string, error)
  19. func ZipFile(filelist []string, outputfile string, includeTopLevelFolder bool) error
  20. TYPES
  21. type FileData struct {
  22. Filename string
  23. Filepath string
  24. Realpath string
  25. IsDir bool
  26. Filesize float64
  27. Displaysize string
  28. }
  29. type FileProperties struct {
  30. VirtualPath string
  31. StoragePath string
  32. Basename string
  33. VirtualDirname string
  34. StorageDirname string
  35. Ext string
  36. MimeType string
  37. Filesize int64
  38. Permission string
  39. LastModTime string
  40. LastModUnix int64
  41. IsDirectory bool
  42. }
  43. type FileSystemHandler struct {
  44. Name string
  45. UUID string
  46. Path string
  47. Hierarchy string
  48. ReadOnly bool
  49. InitiationTime int64
  50. FilesystemDatabase *db.Database
  51. Filesystem string
  52. }
  53. System Handler for returing
  54. func NewFileSystemHandler(option FileSystemOption) (*FileSystemHandler, error)
  55. Create a new file system handler with the given config
  56. func NewFileSystemHandlersFromJSON(jsonContent []byte) ([]*FileSystemHandler, error)
  57. Create a list of file system handler from the given json content
  58. func (fsh *FileSystemHandler) Close()
  59. func (fsh *FileSystemHandler) CreateFileRecord(realpath string, owner string) error
  60. Create a file ownership record
  61. func (fsh *FileSystemHandler) DeleteFileRecord(realpath string) error
  62. Delete a file ownership record
  63. func (fsh *FileSystemHandler) GetFileRecord(realpath string) (string, error)
  64. Read the owner of a file
  65. type FileSystemOption struct {
  66. Name string `json:"name"` //Display name of this device
  67. Uuid string `json:"uuid"` //UUID of this device, e.g. S1
  68. Path string `json:"path"` //Path for the storage root
  69. Access string `json:"access,omitempty"` //Access right, allow {readonly, everyone, user:{username}, group:{groupname}}
  70. Hierarchy string `json:"hierarchy"` //Folder hierarchy, allow {public, user}
  71. Automount bool `json:"automount"` //Automount this device if exists
  72. Filesystem string `json:"filesystem,omitempty"` //Support {"ext4","ext2", "ext3", "fat", "vfat", "ntfs"}
  73. Mountdev string `json:"mountdev,omitempty"` //Device file (e.g. /dev/sda1)
  74. Mountpt string `json:"mountpt,omitempty"` //Device mount point (e.g. /media/storage1)
  75. Username string `json:"username,omitempty"` //Username if the storage require auth
  76. Password string `json:"password,omitempty"` //Password if the storage require auth
  77. }
  78. FileSystem configuration. Append more lines if required.
  79. type TrashedFile struct {
  80. Filename string
  81. Filepath string
  82. FileExt string
  83. IsDir bool
  84. Filesize int64
  85. RemoveTimestamp int64
  86. RemoveDate string
  87. OriginalPath string
  88. OriginalFilename string
  89. }