A simple file system tool
Simple-fs is a collection of filesystem methods. It has grown by the challenges of the developer to the file system.
go get github.com/starmanmaritn/simple-fsimport "github.com/starmanmaritn/simple-fs"
func main() {
fs.SyncFile("src", "dest")
}With the SyncFolder method it is possible to copy elements from a destination folder to a source folder. SyncFolder does not just copy files and folders. It first checks if the file/folder exists at the destination folder. If the file exists it compares the last changed timestamp on the destination and the source. Only if the source timestamp is newer the source gets copied
sourcestring Absolute path to source folderdeststring Absolute path to destination folder
errornil if success. Else some error
With the SyncFolderAndIngonre method is the same as the SyncFolder but it is possible to ignore a list of folders. it is only allowed to add a global folder name as ignored folder. For example .git so all .git folder get ignored
sourcestring Absolute path to source folderdeststring Absolute path to destination folderignoreList...string A list of ignored folder names (Just global folder names)
errornil if success. Else some error
With the SyncFile method it is possible to copy a source element to a destination folder. SyncFile first checks if the file/folder exists at the destination folder. If the file exists it compares the last changed timestamp on the destination and the source. Only if the source timestamp is newer the source gets copied
sourcestring Absolute path to source filedeststring Absolute path to destination folder
errornil if success. Else some error
ReadLines reads a number of lines in a source file.
pathstring Absolute path to source filelineCountsint number of lines to return. -1 to return whole file
[]stringlines of a flieerrornil if success. Else some error
CheckIfFolderUpdated checks if a folders last change is newer then a given time. It compares all sub files and folder to make sure if the folder ist up to date.
sourcestring Absolute path to source folderlastChecktime.Time time to compare last change timestamp of folder
booltrueif the folder and all the sub files and sub folders are up to dateerrornil if success. Else some error
Exists checks if a folders or a file exists.
pathstring Absolute path to the folder or file
booltrueif the folder and existserroronly if file exists but not able to read