private static bool isGoFile(os.FileInfo f) { // ignore non-Go files var name = f.Name(); return(!f.IsDir() && !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go")); }
// FileInfoHeader creates a partially-populated FileHeader from an // os.FileInfo. // Because os.FileInfo's Name method returns only the base name of // the file it describes, it may be necessary to modify the Name field // of the returned header to provide the full path name of the file. // If compression is desired, callers should set the FileHeader.Method // field; it is unset by default. public static (ref FileHeader, error) FileInfoHeader(os.FileInfo fi) { var size = fi.Size(); FileHeader fh = ref new FileHeader(Name: fi.Name(), UncompressedSize64: uint64(size), ); fh.SetModTime(fi.ModTime()); fh.SetMode(fi.Mode()); if (fh.UncompressedSize64 > uint32max) { fh.UncompressedSize = uint32max; } else { fh.UncompressedSize = uint32(fh.UncompressedSize64); } return(fh, null); }