winfileinfo

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2025 License: MIT Imports: 5 Imported by: 0

README

winfileinfo

winfileinfo is a Go module for retrieving file version and file time information on Windows.

Installation

To install the module, use go get:

go get github.com/miroslav-matejovsky/winfileinfo

Usage

Retrieving File Version Information

You can retrieve the file version information using the WinFileInfo struct.

package main

import (
    "fmt"
    "log"

    "github.com/miroslav-matejovsky/winfileinfo"
)

func main() {
    file := `C:\Windows\System32\notepad.exe`
    wf, err := winfileinfo.NewWinFile(file)
    if err != nil {
        log.Fatalf("Error creating WinFile: %v", err)
    }

    fi, err := wf.GetFileInfo()
    if err != nil {
        log.Fatalf("Error getting file info: %v", err)
    }

    fmt.Printf("File Version: %s\n", fi.FileVersion)
    fmt.Printf("Product Version: %s\n", fi.ProductVersion)
}
Retrieving File Time Information

You can retrieve the file time information using the WinFileTime struct.

package main

import (
    "fmt"
    "log"

    "github.com/miroslav-matejovsky/winfileinfo"
)

func main() {
    file := `C:\Windows\System32\notepad.exe`
    wf, err := winfileinfo.NewWinFile(file)
    if err != nil {
        log.Fatalf("Error creating WinFile: %v", err)
    }

    ft, err := wf.GetFileTime()
    if err != nil {
        log.Fatalf("Error getting file time: %v", err)
    }

    fmt.Printf("Creation Time: %s\n", ft.CreationTime)
    fmt.Printf("Last Access Time: %s\n", ft.LastAccessTime)
    fmt.Printf("Last Write Time: %s\n", ft.LastWriteTime)
}

Testing

To run the tests, use the go test command:

go test ./...

License

This project is licensed under the MIT License. See the LICENSE file for details.

Documentation

Overview

Package winfileinfo provides utilities for retrieving file information on Windows systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WinFile

type WinFile struct {
	// contains filtered or unexported fields
}

WinFile represents a file on the Windows filesystem.

func NewWinFile

func NewWinFile(path string) (*WinFile, error)

NewWinFile creates a new WinFile for the given path. It returns an error if the file does not exist or if there is an error checking the file.

func (*WinFile) GetFileInfo

func (wf *WinFile) GetFileInfo() (*WinFileInfo, error)

GetFileInfo retrieves the file version information for the file. It returns a WinFileInfo struct containing the file version information.

func (*WinFile) GetFileTime

func (wf *WinFile) GetFileTime() (*WinFileTime, error)

GetFileTime retrieves the file time information for the file. It returns a WinFileTime struct containing the file time information.

func (*WinFile) GetFixedFileInfo

func (wf *WinFile) GetFixedFileInfo() (*windows.VS_FIXEDFILEINFO, error)

GetFixedFileInfo retrieves the fixed file information for the file. It returns a windows.VS_FIXEDFILEINFO struct containing the fixed file information.

type WinFileInfo

type WinFileInfo struct {
	FileVersion    WinFileVersion
	ProductVersion WinFileVersion
}

type WinFileTime

type WinFileTime struct {
	CreationTime   time.Time
	LastAccessTime time.Time
	LastWriteTime  time.Time
}

type WinFileVersion

type WinFileVersion struct {
	Major uint16
	Minor uint16
	Patch uint16
	Build uint16
}

func (WinFileVersion) String

func (f WinFileVersion) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL