Browse Source

Add symlink support at the protocol level

Audrius Butkevicius 11 years ago
parent
commit
ddc56c8a0d
2 changed files with 17 additions and 4 deletions
  1. 9 0
      message.go
  2. 8 4
      protocol.go

+ 9 - 0
message.go

@@ -58,6 +58,10 @@ func (f FileInfo) IsDirectory() bool {
 	return f.Flags&FlagDirectory != 0
 }
 
+func (f FileInfo) IsSymlink() bool {
+	return f.Flags&FlagSymlink != 0
+}
+
 func (f FileInfo) HasPermissionBits() bool {
 	return f.Flags&FlagNoPermBits == 0
 }
@@ -101,6 +105,10 @@ func (f FileInfoTruncated) IsDirectory() bool {
 	return f.Flags&FlagDirectory != 0
 }
 
+func (f FileInfoTruncated) IsSymlink() bool {
+	return f.Flags&FlagSymlink != 0
+}
+
 func (f FileInfoTruncated) HasPermissionBits() bool {
 	return f.Flags&FlagNoPermBits == 0
 }
@@ -110,6 +118,7 @@ type FileIntf interface {
 	IsDeleted() bool
 	IsInvalid() bool
 	IsDirectory() bool
+	IsSymlink() bool
 	HasPermissionBits() bool
 }
 

+ 8 - 4
protocol.go

@@ -49,10 +49,14 @@ const (
 )
 
 const (
-	FlagDeleted    uint32 = 1 << 12
-	FlagInvalid           = 1 << 13
-	FlagDirectory         = 1 << 14
-	FlagNoPermBits        = 1 << 15
+	FlagDeleted              uint32 = 1 << 12
+	FlagInvalid                     = 1 << 13
+	FlagDirectory                   = 1 << 14
+	FlagNoPermBits                  = 1 << 15
+	FlagSymlink                     = 1 << 16
+	FlagSymlinkMissingTarget        = 1 << 17
+
+	SymlinkTypeMask = FlagDirectory | FlagSymlinkMissingTarget
 )
 
 const (