Ejemplo n.º 1
0
func (self *DirectoryResourceType) Create(ctx types.Context, b []byte) (*types.Message, error) {

	path := string(b)

	if !utils.FileExists(path) || !utils.IsDir(path) {
		return nil, errors.New("path not a file or a directory")
	}

	msg := types.Message{
		"Path": path,
	}

	return &msg, nil
}
Ejemplo n.º 2
0
func (self *DirectoryResource) Create(b []byte) (map[string]interface{}, error) {

	path := string(b)

	if !utils.FileExists(path) || !utils.IsDir(path) {
		return nil, errors.New("path not a file or a directory")
	}

	m := database.Query{
		"Path": path,
	}

	return m, nil
}
Ejemplo n.º 3
0
func initPluginHost(core *Core, config CoreConfig) (host *plugins.PluginHost, err error) {

	defaultPluginPath := filepath.Join(config.ConfigPath, "plugins")

	if !utils.IsDir(defaultPluginPath) {
		err = os.MkdirAll(defaultPluginPath, 0755)
	}

	if err != nil {
		return
	}

	paths := append([]string{defaultPluginPath}, config.PluginPaths...)

	if host, err = plugins.NewPluginHost(plugins.HostConfig{
		Paths:      paths,
		Publisher:  "tcp://127.0.0.1:4000",
		Subscriber: "tcp://127.0.0.1:4001",
	}); err != nil {
		return
	}

	/*go func() {

		for {
			select {
			case plugin := <-host.PluginRegister:
				plugin.Rpc.RegisterFunc("sys", "RegisterResourceType", func(o types.Message, out *types.Message) error {
					*out = nil
					creator := resourceTypeCreator{host, o["PluginId"].(string)}
					return core.Resources.Register(o["Type"].(string), &creator)
				})
			}
		}

	}()*/

	err = host.InitAllPlugins()

	return
}