Documentation
¶
Overview ¶
Package vdf provides utilities to read metadata files (e.g., info.txt and changelog.txt) for mods and workshop items, particularly for Space Engineers Workshop content.
Package vdf provides functions to manage and manipulate VDF (Valve Data Format) files for Steam Workshop items. This includes building VDF files for uploading or updating workshop items, as well as reading existing VDF files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build generates the content of a VDF file based on the provided VDFItem struct. This content is used to upload or update an item in the Steam Workshop.
The function will automatically fill missing fields such as app ID (default 244850), visibility (default 0), and preview file (default: "thumb.png"). It also attempts to retrieve the title and description from an "info.txt" file in the content folder, and the changelog from a "changelog.txt" file if they exist.
Parameters: - item: A VDFItem struct containing the necessary fields to build the VDF file.
Returns: - A string containing the generated VDF file content, or an empty string in case of errors.
func Changelog ¶
Changelog reads the `changelog.txt` file located at the specified mod path and returns its content as a string.
If the file is found and read successfully, the function returns true and the full content of the changelog. If the file is not found or any error occurs, it returns false with an empty string.
Parameters: - modPath: The path to the mod directory containing the `changelog.txt` file.
Returns: - success: A boolean indicating if the file was successfully read. - changelog: The full content of the `changelog.txt` file as a single string.
func Readme ¶
Readme reads the `info.txt` file located at the specified mod path and returns the title and description.
The `info.txt` file is expected to follow this format: - Line 1: Title - Line 2+: Description
If the file is found and read successfully, the function returns true, along with the title and description. If the file is not found or any error occurs, it returns false with empty strings.
Parameters: - modPath: The path to the mod directory containing the `info.txt` file.
Returns: - success: A boolean indicating if the file was successfully read. - title: The title (first line) of the `info.txt` file. - description: The description (remaining lines) of the `info.txt` file.
Types ¶
type VDFItem ¶
type VDFItem struct {
AppID string // The Steam app ID (default: 244850 for Space Engineers)
WorkshopID string // The Steam Workshop ID of the item
ContentFolder string // The absolute path to the content folder
Visibility string // Visibility of the item (0 = public, 1 = friends only, 2 = private)
PreviewFile string // The path to the preview image file
Title string // Title of the workshop item
Description string // Description of the workshop item
ChangeNote string // Changelog or update notes
}
VDFItem represents the necessary fields required to create or read a VDF file. It includes the App ID, Workshop ID, content folder path, visibility, preview file path, title, description, and change note for the item.
func Read ¶
Read reads a VDF file from the provided path and extracts the fields into a VDFItem struct.
The VDF file is expected to contain fields such as appid, publishedfileid, contentfolder, etc. This function will scan through the file line by line, extract the values, and populate the VDFItem struct.
Parameters: - vdfPath: The file path to the VDF file to read.
Returns: - VDFItem: A populated VDFItem struct containing the extracted values. - error: An error if any issues occur while reading the file.