Created
February 7, 2014 09:00
-
-
Save taichi/8859356 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"os" | |
"path/filepath" | |
"syscall" | |
) | |
func main() { | |
fmt.Println("way") | |
path := "foge/moge/rel.txt" | |
if err := os.MkdirAll(filepath.Dir(path), 0644); err != nil { | |
panic(err) | |
} | |
if err := ioutil.WriteFile(path, []byte("aaa"), 0644); err != nil { | |
panic(err) | |
} | |
stat(path) | |
if err := syscall.Chmod(path, 0x1); err != nil { | |
panic(err) | |
} | |
if file, err := os.Open(path); err != nil { | |
panic(err) | |
} else { | |
fmt.Println(file.Name()) | |
file.Close() | |
} | |
stat(path) | |
fmt.Println("ddd") | |
filepath.Walk("foge", | |
func(path string, info os.FileInfo, err error) error { | |
fmt.Println(path, info, err) | |
return nil | |
}) | |
fmt.Println("zzz") | |
if err := os.RemoveAll("foge"); err != nil { | |
if v, ok := err.(*os.PathError); ok { | |
fmt.Println(v.Path) | |
} | |
fmt.Println(err.Error()) | |
} | |
if err := syscall.Chmod(path, syscall.S_IWRITE); err != nil { | |
panic(err) | |
} | |
fmt.Println("####") | |
} | |
func stat(path string) { | |
if info, err := os.Lstat(path); err != nil { | |
panic(err) | |
} else { | |
fmt.Println(info.Mode()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment