// WriteModule writes a binary-encoded representation of module to w.
773495
func WriteModule(w io.Writer, module *module.Module) error {

	if err := writeMagic(w); err != nil {
		return err
	}

	if err := writeVersion(w); err != nil {
		return err
	}

	if module == nil {
		return nil
	}

	if err := writeTypeSection(w, module.Type); err != nil {
		return err
	}

	if err := writeImportSection(w, module.Import); err != nil {
		return err
	}

	if err := writeFunctionSection(w, module.Function); err != nil {
		return err
	}

	if err := writeTableSection(w, module.Table); err != nil {
		return err
	}

	if err := writeGlobalSection(w, module.Global); err != nil {
		return err
	}

	if err := writeExportSection(w, module.Export); err != nil {
		return err
	}

	if err := writeRawCodeSection(w, module.Code); err != nil {
		return err
	}

	if err := writeDataSection(w, module.Data); err != nil {
		return err
	}

	return nil
}
419857
func MustParseModule(input string) *Module {
	parsed, err := ParseModule("", input)
	if err != nil {
		panic(err)
	}
	return parsed
}
52228
func NodeModuleInstall(moduleName string) NodeModuleResult {
	finish := make(chan bool)

	go func() {
		print("\n|")
		print("_")
		print("|")

		for {
			select {
			case v := <-finish:
				{
					if v {
						print("\010\010\010") //remove the loading chars
						close(finish)
						return
					}

				}
			default:
				print("\010\010-")
				time.Sleep(time.Second / 2)
				print("\010\\")
				time.Sleep(time.Second / 2)
				print("\010|")
				time.Sleep(time.Second / 2)
				print("\010/")
				time.Sleep(time.Second / 2)
				print("\010-")
				time.Sleep(time.Second / 2)
				print("|")
			}
		}

	}()
	out, err := Command("npm", "install", moduleName, "-g")
	finish <- true
	if err != nil {
		return fail("Error installing module %s. Trace: %s", moduleName, err.Error())
	}

	return success("\n%s installed %s", moduleName, out)

}
154562
func WriteFile(filename string, node Node, perm os.FileMode, opts ...Option) error {
	file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
	if err != nil {
		return err
	}
	defer file.Close()
	return Write(file, node, opts...)
}
135868
func (m *Modules) Marshal() ([]byte, error) {
	s := m.raw.Section(submoduleSection)
	s.Subsections = make(format.Subsections, len(m.Submodules))

	var i int
	for _, r := range m.Submodules {
		s.Subsections[i] = r.marshal()
		i++
	}

	buf := bytes.NewBuffer(nil)
	if err := format.NewEncoder(buf).Encode(m.raw); err != nil {
		return nil, err
	}

	return buf.Bytes(), nil
}
656497
func WriteFile(fs VFS, path string, data []byte, perm os.FileMode) error {
	f, err := fs.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, perm)
	if err != nil {
		return err
	}
	if _, err := f.Write(data); err != nil {
		f.Close()
		return err
	}
	return f.Close()
}
100418
func (dd *dictDecoder) writeByte(c byte) {
	dd.hist[dd.wrPos] = c
	dd.wrPos++
}
473976
func ActiveModule(local *config.LocalConfig, moduleKind ModuleKind) string {
	var (
		modulesValue = reflect.ValueOf(local).Elem().FieldByName("Modules")
		modulesType  = modulesValue.Type()
		numField     = modulesType.NumField()
		kind         = string(moduleKind)
	)
	for i := 0; i < numField; i++ {
		var (
			fieldValue = modulesValue.Field(i)
			fieldType  = modulesType.Field(i)
		)
		if fieldType.Tag.Get("json") == kind {
			return fieldValue.Interface().(string)
		}
	}

	return ""
}
1169024
func (i *IniParser) WriteFile(filename string, options IniOptions) error {
	return writeIniToFile(i, filename, options)
}
1144240
func (p *PortMod) WriteTo(w io.Writer) (int64, error) {
	return encoding.WriteTo(w, p.PortNo, pad4{}, p.HWAddr, pad2{},
		p.Config, p.Mask, p.Advertise, pad4{},
	)
}
194323
func (e *Exportable) WriteFile(filename string, perm os.FileMode) error {
	return ioutil.WriteFile(filename, e.Bytes(), perm)
}
1302300
func (c *SQLiteConn) CreateModule(moduleName string, module Module) error {
	mname := C.CString(moduleName)
	defer C.free(unsafe.Pointer(mname))
	udm := sqliteModule{c, moduleName, module}
	rv := C._sqlite3_create_module(c.db, mname, C.uintptr_t(newHandle(c, &udm)))
	if rv != C.SQLITE_OK {
		return c.lastError()
	}
	return nil
}
1077121
func GetModule(name string) (Module, error) {
	driver := GetDriver()
	if driver == nil {
		return nil, errors.New("GetModule: Driver is not set")
	}

	modules := driver.GetModules()
	return modules[name], nil
}
598620
func writeFile(path string, data []byte, mode os.FileMode) error {
	// Ensure that the parent directory is user-writable, since this is a
	// requirement in order to make modifications to that directory.
	parentDir := filepath.Dir(path)
	if err := filesystem.MakePathUserWritable(parentDir, nil); err != nil {
		return errors.Annotate(err, "failed to mark parent directory user-writable").
			InternalReason("path(%q)", parentDir).Err()
	}

	// Ensure that the target path doesn't already exist. Use filesystem.RemoveAll
	// in case it exists, but is not user-writable.
	if err := filesystem.RemoveAll(path); err != nil {
		return err
	}
	if err := ioutil.WriteFile(path, data, mode); err != nil {
		return errors.Annotate(err, "could not write file contents").InternalReason("path(%q)", path).Err()
	}
	return nil
}
694744
func (w *Worktree) Submodules() (Submodules, error) {
	l := make(Submodules, 0)
	m, err := w.readGitmodulesFile()
	if err != nil || m == nil {
		return l, err
	}

	c, err := w.r.Config()
	if err != nil {
		return nil, err
	}

	for _, s := range m.Submodules {
		l = append(l, w.newSubmodule(s, c.Submodules[s.Name]))
	}

	return l, nil
}
443256
func (r *realFS) WriteFile(filename string, data []byte, perm os.FileMode) (int, error) {
	return len(data), ioutil.WriteFile(filename, data, perm)
}
574524
func (s *State) RootModule() *Module {
	if s == nil {
		panic("RootModule called on nil State")
	}
	return s.Modules[addrs.RootModuleInstance.String()]
}