Skip to content

package project_file_system

import "kaiju/editor/project/project_file_system"

Constants

DatabaseFolder

"database"

ContentFolder

"database/content"

ContentConfigFolder

"database/config"

SrcFolder

"database/src"

StockFolder

"database/stock"

ProjectConfigFile

"database/project.json"

SrcFontFolder

SrcFolder + "/font"

SrcCharsetFolder

SrcFolder + "/font/charset"

SrcPluginFolder

SrcFolder + "/plugin"

SrcRenderFolder

SrcFolder + "/render"

SrcShaderFolder

SrcFolder + "/render/shader"

ContentAudioFolder

"audio"

ContentMusicFolder

"audio/music"

ContentSoundFolder

"audio/sound"

ContentFontFolder

"font"

ContentMeshFolder

"mesh"

ContentRenderFolder

"render"

ContentMaterialFolder

"render/material"

ContentRenderPassFolder

"render/renderpass"

ContentShaderFolder

"render/shader"

ContentShaderPipelineFolder

"render/pipeline"

ContentSpvFolder

"render/spv"

ContentStageFolder

"stage"

ContentTextureFolder

"texture"

ContentUiFolder

"ui"

ContentHtmlFolder

"ui/html"

ContentCssFolder

"ui/css"

KaijuSrcFolder

"kaiju"

ProjectCodeFolder

"src"

ProjectFileTemplates

KaijuSrcFolder + "/file_templates"

ProjectCodeGameHostFolder

ProjectCodeFolder + "/game_host"

ProjectBuildFolder

"build"

ProjectBuildAndroidFolder

ProjectBuildFolder + "/android"

ProjectVSCodeFolder

".vscode"

ProjectLaunchJsonFile

".vscode/launch.json"

ProjectCodeMain

ProjectCodeFolder + "/main

ProjectCodeGame

ProjectCodeFolder + "/game

ProjectModFile

ProjectCodeFolder + "/go

ProjectCodeGameHost

ProjectCodeGameHostFolder + "/game_host

ProjectWorkFile

"go.work"

ProjectCodeGameTitle

KaijuSrcFolder + "/build/title

EntityDataBindingInit

ProjectCodeFolder + "/entity_data_binding_init

Types

EngineFileSystem

struct

type EngineFileSystem struct{ embed.FS }

var EngineFS EngineFileSystem

EngineFileSystem.CopyFolder

func (efs EngineFileSystem) CopyFolder(pfs *FileSystem, from, to string, skipExt []string) error

FileSystem

struct

type FileSystem struct {
    *os.Root
}

FileSystem is the rooted project folder that is responsible for accessing any files or folders within the project. The type is a composition of os.Root, so all functions availabe to that structure are available to this one. Helper functions specific to projects are extended to it's behavior.

The FileSystem has no awareness of actual content/assets and simply understands the structure for the project and allows raw read/write access to the files within the project.

New

func New(rootPath string) (FileSystem, error)

New creates a new FileSystem that is rooted to the given project path. This function does not care about the status of the given path and only expects that the path supplied is to a folder on the filesystem. If the supplied path does not exist, an attempt will be made to create the folder.

FileSystem.EnsureDatabaseExists

func (fs *FileSystem) EnsureDatabaseExists() error

Used to review the loaded FileSystem to ensure that the primary folders required for this rooted FileSystem are present to be considered a project. This will return an error if the core files are missing. Please review the source code file for this function to review the required core files and folders used, they are set as local package variables.

FileSystem.Exists

func (fs *FileSystem) Exists(name string) bool

Exists will return true if the target file or folder exists in the rooted file system

FileSystem.FileExists

func (fs *FileSystem) FileExists(name string) bool

FileExists will return true if the file exists in the rooted file system

FileSystem.FolderExists

func (fs *FileSystem) FolderExists(name string) bool

FolderExists will return true if the folder exists in the rooted file system

FileSystem.FullPath

func (fs *FileSystem) FullPath(name string) string

FullPath will return the a cleaned version of the rooted file system path with the supplied name joined onto it.

FileSystem.IsValid

func (fs *FileSystem) IsValid() bool

IsValid will return true if this project file system has been setup already.

FileSystem.NormalizePath

func (fs *FileSystem) NormalizePath(path string) string

NormalizePath will attempt to determine if the input path is a location held within the project file system. If it is a path within this file systme, then it will return the path as a relative path to the system, otherwise it will return the path supplied.

FileSystem.ReadDir

func (fs *FileSystem) ReadDir(name string) ([]os.DirEntry, error)

ReadDir is a wrapper around os.ReadDir since os.Root doesn't provide an interface to this function directly. This simply grabs the rooted directory path and joins the name argument to it before forwarding to os.ReadDir.

FileSystem.ReadModName

func (pfs *FileSystem) ReadModName() string

FileSystem.SetupStructure

func (fs *FileSystem) SetupStructure() error

SetupStructure goes through and ensure all the base folders are created for the project. This will only create the folders if they do not yet exist. Folders are often missing if pulling the project from version control, as empty folders are not typically submitted. For more information on folder structure layout, please review the high level editor design documentation in the README.

FileSystem.TryUpgrade

func (fs *FileSystem) TryUpgrade() error

FileSystem.WriteDataBindingRegistryInit

func (pfs *FileSystem) WriteDataBindingRegistryInit(g []codegen.GeneratedType) error

PathError

struct

type PathError struct {
    Path string
    Msg  string
    Err  error
}

PathError.Error

func (e PathError) Error() string