X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=cmd%2Fmicro%2Frtfiles.go;h=a72b6ee35b1299c697a3867e9693cd5f7fac2193;hb=71af765b4e4f368c4bbbcb3947f3497e17271b62;hp=602d4e84e1ea990c79497e4ebc25d1bce5fabaaf;hpb=2e6cbcb362a4eba98a0019538d8fd6d924745f16;p=micro.git diff --git a/cmd/micro/rtfiles.go b/cmd/micro/rtfiles.go index 602d4e84..a72b6ee3 100644 --- a/cmd/micro/rtfiles.go +++ b/cmd/micro/rtfiles.go @@ -37,6 +37,19 @@ type namedFile struct { name string } +// a file with the data stored in memory +type memoryFile struct { + name string + data []byte +} + +func (mf memoryFile) Name() string { + return mf.name +} +func (mf memoryFile) Data() ([]byte, error) { + return mf.data, nil +} + func (rf realFile) Name() string { fn := filepath.Base(string(rf)) return fn[:len(fn)-len(filepath.Ext(fn))] @@ -187,3 +200,8 @@ func PluginAddRuntimeFilesFromDirectory(plugin, filetype, directory, pattern str AddRuntimeFilesFromAssets(filetype, fullpath, pattern) } } + +// PluginAddRuntimeFileFromMemory adds a file to the runtime files for a plugin from a given string +func PluginAddRuntimeFileFromMemory(plugin, filetype, filename, data string) { + AddRuntimeFile(filetype, memoryFile{filename, []byte(data)}) +}