func (self *FindFile) Close() error { if self.handle != 0 { if err := wrappers.FindClose(self.handle); err != nil { return NewWindowsError("FindClose", err) } self.handle = 0 wrappers.RtlZeroMemory((*byte)(unsafe.Pointer(&self.current)), unsafe.Sizeof(self.current)) } return nil }
func FileExists(fileName string) (bool, error) { var wfd wrappers.WIN32_FIND_DATA handle, err := wrappers.FindFirstFile(syscall.StringToUTF16Ptr(fileName), &wfd) if err == wrappers.ERROR_FILE_NOT_FOUND { return false, nil } else if err != nil { return false, NewWindowsError("FindFirstFile", err) } wrappers.FindClose(handle) return true, nil }