示例#1
0
func UnzipFS(nam string) {
	log := "syscall.UnzipFS() unzip file: " + nam + "\n"
	if len(nam) > 5 && nam[len(nam)-4:] == ".zip" {
		log += unzip(string(hx.Resource(nam)))
	} else {
		log += "syscall.UnzipFS() not a .zip file - ignored\n"
	}
	// TODO append to the log file if it exists, to allow multiple UnzipFS calls to be logged properly
	//fd, err := Open(nam, O_CREATE|O_EXCL, 0666) // replaced with code below to avoid init loop
	f, err := fs.open("/unzipfs.log", O_CREATE|O_WRONLY, 0666|S_IFREG)
	fd := newFD(f)
	// end code replacement
	if err != nil {
		println("information: syscall.UnzipFS() unable to syscall.Open() /unzipfs.log : " + err.Error())
	} else {
		defer Close(fd)
		sz, err := Write(fd, []byte(log))
		if err != nil || sz != len(log) {
			println("information: syscall.UnzipFS() bad syscall.Write() (size or error) for /unzipfs.log" +
				" : " + err.Error())
		}
	}
}
示例#2
0
							if err == nil {
								log += "syscall.fsinit() loaded file: " + subPath + "/\n"
							}
						}
					}
				}
				//fd, err := Open(nam, O_CREATE|O_EXCL, 0666) // replaced with code below to avoid init loop
				f, err := fs.open(nam, O_CREATE|O_WRONLY, 0666|S_IFREG)
				fd := newFD(f)
				// end code replacement
				if err != nil {
					log += "syscall.fsinit() unable to syscall.Open() for " +
						nam + " : " + err.Error() + "\n"
				} else {
					defer Close(fd)
					b := hx.Resource(nam)
					if b == nil || len(b) == 0 {
						log += "syscall.fsinit() hx.Resource() file empty for: " + nam + "\n"
					} else {
						sz, err := Write(fd, b)
						if err != nil || sz != len(b) {
							log += "syscall.fsinit() bad syscall.Write() (size or error) for " +
								nam + " : " + err.Error() + "\n"
						} else {
							log += "syscall.fsinit() loaded file: " + nam + "\n"
						}
					}
				}
			}
		}
		//fd, err := Open(nam, O_CREATE|O_EXCL, 0666) // replaced with code below to avoid init loop