...
1
2
3 package config
4
5 import (
6 "os"
7 "path/filepath"
8
9 "github.com/tetratelabs/wazero/internal/platform"
10 )
11
12 type Config struct {
13 OsWorkdir bool
14
15
16 Workdir string
17 Umask uint32
18 }
19
20 func NewConfig() *Config {
21 return &Config{
22 OsWorkdir: false,
23 Workdir: "/",
24 Umask: uint32(0o0022),
25 }
26 }
27
28 func (c *Config) Clone() *Config {
29 ret := *c
30 return &ret
31 }
32
33 func (c *Config) Init() error {
34 if c.OsWorkdir {
35 workdir, err := os.Getwd()
36 if err != nil {
37 return err
38 }
39
40 workdir = platform.ToPosixPath(workdir)
41
42 c.Workdir = workdir[len(filepath.VolumeName(workdir)):]
43 }
44 return nil
45 }
46
View as plain text