// OpenFTP FTP接続開始
339307
func (api *CDROMAPI) OpenFTP(id int64, reset bool) (*sacloud.FTPServer, error) {
	var (
		method = "PUT"
		uri    = fmt.Sprintf("%s/%d/ftp", api.getResourceURL(), id)
		body   = map[string]bool{"ChangePassword": reset}
		res    = &sacloud.Response{}
	)

	result, err := api.action(method, uri, body, res)
	if !result || err != nil {
		return nil, err
	}

	return res.FTPServer, nil
}
828328
func IOOpen(l *State) int {
	NewLibrary(l, ioLibrary)

	NewMetaTable(l, fileHandle)
	l.PushValue(-1)
	l.SetField(-2, "__index")
	SetFunctions(l, fileHandleMethods, 0)
	l.Pop(1)

	registerStdFile(l, os.Stdin, input, "stdin")
	registerStdFile(l, os.Stdout, output, "stdout")
	registerStdFile(l, os.Stderr, "", "stderr")

	return 1
}
233273
func (s *StanServer) ftSetup() error {
	// Check that store type is ok. So far only support for FileStore
	if s.opts.StoreType != stores.TypeFile && s.opts.StoreType != stores.TypeSQL {
		return fmt.Errorf("ft: only %v or %v stores supported in FT mode", stores.TypeFile, stores.TypeSQL)
	}
	// So far, those are not exposed to users, just used in tests.
	// Still make sure that the missed HB interval is > than the HB
	// interval.
	if ftHBMissedInterval < time.Duration(float64(ftHBInterval)*1.1) {
		return fmt.Errorf("ft: the missed heartbeat interval needs to be"+
			" at least 10%% of the heartbeat interval (hb=%v missed hb=%v",
			ftHBInterval, ftHBMissedInterval)
	}
	// Set the HB and MissedHB intervals, using a bit of randomness
	rand.Seed(time.Now().UnixNano())
	s.ftHBInterval = ftGetRandomInterval(ftHBInterval)
	s.ftHBMissedInterval = ftGetRandomInterval(ftHBMissedInterval)
	// Subscribe to FT subject
	s.ftSubject = fmt.Sprintf("%s.%s.%s", ftHBPrefix, s.opts.ID, s.opts.FTGroupName)
	s.ftHBCh = make(chan *nats.Msg)
	sub, err := s.ftnc.Subscribe(s.ftSubject, func(m *nats.Msg) {
		// Dropping incoming FT HBs is not crucial, we will then check for
		// store lock.
		select {
		case s.ftHBCh <- m:
		default:
		}
	})
	if err != nil {
		return fmt.Errorf("ft: unable to subscribe on ft subject: %v", err)
	}
	// We don't want to cause possible slow consumer error
	sub.SetPendingLimits(-1, -1)
	// Create channel to notify FT go routine to quit.
	s.ftQuit = make(chan struct{}, 1)
	// Set the state as standby initially
	s.state = FTStandby
	return nil
}
92565
func OpenFileForWriting(fs afero.Fs, filename string) (afero.File, error) {
	filename = filepath.Clean(filename)
	// Create will truncate if file already exists.
	// os.Create will create any new files with mode 0666 (before umask).
	f, err := fs.Create(filename)
	if err != nil {
		if !os.IsNotExist(err) {
			return nil, err
		}
		if err = fs.MkdirAll(filepath.Dir(filename), 0777); err != nil { //  before umask
			return nil, err
		}
		f, err = fs.Create(filename)
	}

	return f, err
}
480184
func (fs *FS) OpenFile(name string, flag int, perm os.FileMode) (vfs.File, error) {
	return fs.Filesystem.OpenFile(fs.PrefixPath(name), flag, perm)
}
576960
func (c *remoteConn) OpenChannel(name string, data []byte) (ssh.Channel, error) {
	channel, _, err := c.sconn.OpenChannel(name, data)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	return channel, nil
}
1162112
func (s *StdoutClient) CreateTCPSocket() error {
	if s.FD == nil {
		s.FD = os.Stdout
	}
	return nil
}
240665
func (xff *XFF) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
	r.RemoteAddr = GetRemoteAddrIfAllowed(r, xff.allowed)
	next(w, r)
}
425937
func Connect(addr string) (*FTP, error) {
	var err error
	var conn net.Conn

	if conn, err = net.Dial("tcp", addr); err != nil {
		return nil, err
	}

	writer := bufio.NewWriter(conn)
	reader := bufio.NewReader(conn)

	//reader.ReadString('\n')
	object := &FTP{conn: conn, addr: addr, reader: reader, writer: writer, debug: false}
	object.receive()

	return object, nil
}
702505
func (fs OsFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
	return os.OpenFile(name, flag, perm)
}
40765
func (fp FsPath) Open() (ReadCloser, error) {
	return fp.Fs.Open(fp.Path)
}
615623
func ConnectDbg(addr string) (*FTP, error) {
	var err error
	var conn net.Conn

	if conn, err = net.Dial("tcp", addr); err != nil {
		return nil, err
	}

	writer := bufio.NewWriter(conn)
	reader := bufio.NewReader(conn)

	var line string

	object := &FTP{conn: conn, addr: addr, reader: reader, writer: writer, debug: true}
	line, _ = object.receive()

	log.Print(line)

	return object, nil
}
988624
func (p *parserMixin) OpenFile(flag int, perm os.FileMode) (target **os.File) {
	target = new(*os.File)
	p.OpenFileVar(target, flag, perm)
	return
}
298335
func (ftp *FTP) Upload(localPath string) (err error) {
	fInfo, err := os.Stat(localPath)
	if err != nil {
		return err
	}

	switch {
	case fInfo.IsDir():
		return ftp.copyDir(localPath)
	case fInfo.Mode()&os.ModeType == 0:
		return ftp.copyFile(localPath, filepath.Base(localPath))
	default:
		// Ignore other special files
	}

	return nil
}
1252509
func (fs onlyfilesFS) Open(name string) (http.File, error) {
	f, err := fs.fs.Open(name)
	if err != nil {
		return nil, err
	}
	return neuteredReaddirFile{f}, nil
}
1248946
func OpenFile(path string) error {
	logFilePath = path

	var err error
	logFile, err = os.OpenFile(logFilePath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
	if err != nil {
		return err
	}

	SetOutput(logFile)
	return nil
}
453961
func (sl *Slack) FilesUpload(opt *FilesUploadOpt) (file *UploadedFile, err error) {
	req, err := sl.createFilesUploadRequest(opt)

	if err != nil {
		return
	}

	body, err := sl.DoRequest(req)

	if err != nil {
		return
	}

	res := new(FilesUploadAPIResponse)
	err = json.Unmarshal(body, res)

	if err != nil {
		return
	}

	if res.Ok {
		file = &res.File
	} else {
		err = errors.New(res.Error)
	}

	return
}