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-fs
import "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
source
string Absolute path to source folderdest
string Absolute path to destination folder
error
nil 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
source
string Absolute path to source folderdest
string Absolute path to destination folderignoreList
...string A list of ignored folder names (Just global folder names)
error
nil 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
source
string Absolute path to source filedest
string Absolute path to destination folder
error
nil if success. Else some error
ReadLines reads a number of lines in a source file.
path
string Absolute path to source filelineCounts
int number of lines to return. -1 to return whole file
[]string
lines of a flieerror
nil 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.
source
string Absolute path to source folderlastCheck
time.Time time to compare last change timestamp of folder
bool
true
if the folder and all the sub files and sub folders are up to dateerror
nil if success. Else some error
Exists checks if a folders or a file exists.
path
string Absolute path to the folder or file
bool
true
if the folder and existserror
only if file exists but not able to read