Beispiel #1
0
func (tf teefs) writefi(path string, fi os.FileInfo) (err error) {
	if fi.IsDir() {
		err = tf.write.MkdirAll(path, fi.Mode())
	} else {
		if err = tf.write.MkdirAll(filepath.Dir(path), fi.Mode()); err != nil {
			return
		}
		if fi, err = tf.write.Stat(path); os.IsNotExist(err) {
			var mf fs.File
			if mf, err = tf.write.Create(path); err == nil {
				mf.Close()
			}
		}
	}
	return
}
Beispiel #2
0
func (tf teefile) Readdir(n int) (fi []os.FileInfo, err error) {
	if fi, err = tf.File.Readdir(n); err != nil {
		return
	}
	var f fs.File
	for _, fi := range fi {
		path := filepath.Join(tf.dir, filepath.Base(fi.Name()))
		if fi.IsDir() {
			err = tf.write.Mkdir(path, fi.Mode())
		} else {
			if f, err = tf.write.Create(path); err == nil {
				f.Close()
			}
		}
	}
	return
}
Beispiel #3
0
func (tf teefs) Create(path string) (f fs.File, err error) {
	if f, err = tf.read.Create(path); err != nil {
		return
	}
	var fi os.FileInfo
	if fi, err = f.Stat(); err != nil {
		f.Close()
		return
	}
	if err = tf.write.MkdirAll(filepath.Base(path), fi.Mode()); err != nil {
		f.Close()
		return
	}
	var mf fs.File
	if mf, err = tf.write.Create(path); err != nil {
		f.Close()
		return
	}
	mf.Close()
	return
}