mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 18:41:59 -07:00
09832abe50
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3032
42 lines
867 B
Go
42 lines
867 B
Go
// Copyright (C) 2016 The Syncthing Authors.
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package config
|
|
|
|
type FolderType int
|
|
|
|
const (
|
|
FolderTypeReadWrite FolderType = iota // default is readwrite
|
|
FolderTypeReadOnly
|
|
)
|
|
|
|
func (t FolderType) String() string {
|
|
switch t {
|
|
case FolderTypeReadWrite:
|
|
return "readwrite"
|
|
case FolderTypeReadOnly:
|
|
return "readonly"
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
func (t FolderType) MarshalText() ([]byte, error) {
|
|
return []byte(t.String()), nil
|
|
}
|
|
|
|
func (t *FolderType) UnmarshalText(bs []byte) error {
|
|
switch string(bs) {
|
|
case "readwrite":
|
|
*t = FolderTypeReadWrite
|
|
case "readonly":
|
|
*t = FolderTypeReadOnly
|
|
default:
|
|
*t = FolderTypeReadWrite
|
|
}
|
|
return nil
|
|
}
|