-
Notifications
You must be signed in to change notification settings - Fork 8
/
folderchange.go
52 lines (43 loc) · 1.54 KB
/
folderchange.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2013 Andreas Koch. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package fswatch
import (
"fmt"
"time"
)
// newFolderChange creates a new FolderChange instance from the given list if new, moved and modified items.
func newFolderChange(newItems, movedItems, modifiedItems []string) *FolderChange {
return &FolderChange{
timeStamp: time.Now(),
newItems: newItems,
movedItems: movedItems,
modifiedItems: modifiedItems,
}
}
// FolderChange represents changes (new, moved and modified items) of a folder at a given time.
type FolderChange struct {
timeStamp time.Time
newItems []string
movedItems []string
modifiedItems []string
}
func (folderChange *FolderChange) String() string {
return fmt.Sprintf("Folderchange (timestamp: %s, new: %d, moved: %d)", folderChange.timeStamp, len(folderChange.New()), len(folderChange.Moved()))
}
// TimeStamp retunrs the time stamp of the current folder change.
func (folderChange *FolderChange) TimeStamp() time.Time {
return folderChange.timeStamp
}
// New returns the new items of the current folder change.
func (folderChange *FolderChange) New() []string {
return folderChange.newItems
}
// Moved returns the moved items of the current folder change.
func (folderChange *FolderChange) Moved() []string {
return folderChange.movedItems
}
// Modified returns the modified items of the current folder change.
func (folderChange *FolderChange) Modified() []string {
return folderChange.modifiedItems
}