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 }
func (self *FindFile) Next() (bool, error) { if self.handle == 0 { handle, err := wrappers.FindFirstFile(syscall.StringToUTF16Ptr(self.fileName), &self.current) if err == wrappers.ERROR_FILE_NOT_FOUND { return false, nil } else if err != nil { return false, NewWindowsError("FindFirstFile", err) } self.handle = handle } else { if err := wrappers.FindNextFile(self.handle, &self.current); err == wrappers.ERROR_NO_MORE_FILES { return false, nil } else if err != nil { return false, NewWindowsError("FindNextFile", err) } } return true, nil }