Home | History | Annotate | Download | only in fs
      1 // Copyright 2017 Google Inc. All rights reserved.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 package fs
     16 
     17 import (
     18 	"fmt"
     19 	"os"
     20 	"syscall"
     21 	"time"
     22 )
     23 
     24 func (osFs) InodeNumber(info os.FileInfo) (number uint64, err error) {
     25 	sys := info.Sys()
     26 	darwinStats, ok := sys.(*syscall.Stat_t)
     27 	if ok {
     28 		return darwinStats.Ino, nil
     29 	}
     30 	return 0, fmt.Errorf("%v is not a *syscall.Stat_t", sys)
     31 }
     32 
     33 func (osFs) DeviceNumber(info os.FileInfo) (number uint64, err error) {
     34 	sys := info.Sys()
     35 	darwinStats, ok := sys.(*syscall.Stat_t)
     36 	if ok {
     37 		return uint64(darwinStats.Dev), nil
     38 	}
     39 	return 0, fmt.Errorf("%v is not a *syscall.Stat_t", sys)
     40 }
     41 
     42 func (osFs) PermTime(info os.FileInfo) (when time.Time, err error) {
     43 	sys := info.Sys()
     44 	darwinStats, ok := sys.(*syscall.Stat_t)
     45 	if ok {
     46 		return time.Unix(darwinStats.Ctimespec.Sec, darwinStats.Ctimespec.Nsec), nil
     47 	}
     48 	return time.Time{}, fmt.Errorf("%v is not a *syscall.Stat_t", sys)
     49 }
     50