2022-02-09 19:42:28 +03:00
|
|
|
/*
|
|
|
|
_____ _____ _____ ____ ______ _____ ------
|
|
|
|
| | | | | | | | | | | | |
|
|
|
|
| | | | | | | | | | | | |
|
|
|
|
| --- | | | | |-----| |---- | | |-----| |----- ------
|
|
|
|
| | | | | | | | | | | | |
|
|
|
|
| ____| |_____ | ____| | ____| | |_____| _____| |_____ |_____
|
|
|
|
|
|
|
|
|
|
|
|
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
|
|
|
|
2023-01-07 05:41:07 +03:00
|
|
|
Copyright © 2020-2023 Microsoft Corporation. All rights reserved.
|
2022-02-09 19:42:28 +03:00
|
|
|
Author : <blobfusedev@microsoft.com>
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE
|
|
|
|
*/
|
|
|
|
|
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"time"
|
2022-07-27 09:49:36 +03:00
|
|
|
|
|
|
|
"github.com/Azure/azure-storage-fuse/v2/common"
|
2022-02-09 19:42:28 +03:00
|
|
|
)
|
|
|
|
|
2022-02-19 13:26:43 +03:00
|
|
|
func NewDirBitMap() common.BitMap16 {
|
|
|
|
bm := common.BitMap16(0)
|
2022-02-09 19:42:28 +03:00
|
|
|
bm.Set(PropFlagIsDir)
|
|
|
|
return bm
|
|
|
|
}
|
|
|
|
|
2022-02-19 13:26:43 +03:00
|
|
|
func NewSymlinkBitMap() common.BitMap16 {
|
|
|
|
bm := common.BitMap16(0)
|
2022-02-09 19:42:28 +03:00
|
|
|
bm.Set(PropFlagSymlink)
|
|
|
|
return bm
|
|
|
|
}
|
|
|
|
|
2022-02-19 13:26:43 +03:00
|
|
|
func NewFileBitMap() common.BitMap16 {
|
|
|
|
bm := common.BitMap16(0)
|
2022-02-09 19:42:28 +03:00
|
|
|
return bm
|
|
|
|
}
|
|
|
|
|
2022-02-19 13:26:43 +03:00
|
|
|
// Flags represented in common.BitMap16 for various properties of the object
|
2022-02-09 19:42:28 +03:00
|
|
|
const (
|
|
|
|
PropFlagUnknown uint16 = iota
|
|
|
|
PropFlagNotExists
|
|
|
|
PropFlagIsDir
|
|
|
|
PropFlagEmptyDir
|
|
|
|
PropFlagSymlink
|
|
|
|
PropFlagMetadataRetrieved
|
|
|
|
PropFlagModeDefault // TODO: Does this sound better as ModeDefault or DefaultMode? The getter would be IsModeDefault or IsDefaultMode
|
|
|
|
)
|
|
|
|
|
|
|
|
// ObjAttr : Attributes of any file/directory
|
|
|
|
type ObjAttr struct {
|
2022-08-25 14:19:56 +03:00
|
|
|
Mtime time.Time // modified time
|
|
|
|
Atime time.Time // access time
|
|
|
|
Ctime time.Time // change time
|
|
|
|
Crtime time.Time // creation time
|
|
|
|
Size int64 // size of the file/directory
|
|
|
|
Mode os.FileMode // permissions in 0xxx format
|
|
|
|
Flags common.BitMap16 // flags
|
|
|
|
Path string // full path
|
|
|
|
Name string // base name of the path
|
|
|
|
MD5 []byte
|
2022-03-23 21:00:13 +03:00
|
|
|
Metadata map[string]string // extra information to preserve
|
2022-02-09 19:42:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsDir : Test blob is a directory or not
|
|
|
|
func (attr *ObjAttr) IsDir() bool {
|
|
|
|
return attr.Flags.IsSet(PropFlagIsDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsSymlink : Test blob is a symlink or not
|
|
|
|
func (attr *ObjAttr) IsSymlink() bool {
|
|
|
|
return attr.Flags.IsSet(PropFlagSymlink)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsMetadataRetrieved : Whether or not metadata has been retrieved for this path.
|
|
|
|
// Datalake list paths does not support returning x-ms-properties (metadata), so we cannot be sure if the path is a symlink or not.
|
|
|
|
func (attr *ObjAttr) IsMetadataRetrieved() bool {
|
|
|
|
return attr.Flags.IsSet(PropFlagMetadataRetrieved)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsModeDefault : Whether or not to use the default mode.
|
|
|
|
// This is set in any storage service that does not support chmod/chown.
|
|
|
|
func (attr *ObjAttr) IsModeDefault() bool {
|
|
|
|
return attr.Flags.IsSet(PropFlagModeDefault)
|
|
|
|
}
|