iocomponent

package module
v0.0.0-...-80f4f39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2020 License: GPL-2.0, GPL-3.0 Imports: 4 Imported by: 0

README

qml-go-iocomponent

Input Output component

About package

It is simple package for working with text files.

How to use

Initialization in Go

You should to register package as QML component.

func run() error {
    iocomponent.Register("fullappname")
    ui.SetEngine()

    ui.InitModels()
    err := ui.SetComponent()
    if err != nil {
        return err
    }
    ui.Win.Show()
    ui.Win.Wait()

    return nil
}

"fullappname" is name of your program, for example "by.roker2.mega".

3 writable folders

UBports provide 3 writable folders for save and read your program data:

  • /home/phablet/.config/fullappname/

  • /home/phablet/.cache/fullappname/

  • /home/phablet/.local/share/fullappname/

This package use "folderType" for choosing folder. "folderType" is int

  • Config is 0
  • Cache is 1
  • AppData is 2
Initialization in QML
import GoIOComponent 0.1

IOComponent {
    id: io
}
Functions
Write to file
WriteToFile(ft folderType, fileName string, text string)
Read from file
ReadFromFile(ft folderType, fileName string) string
File is exist
FileIsExist(ft folderType, fileName string) bool
Create file
CreateFile(ft folderType, fileName string)
Remove file
RemoveFile(ft folderType, fileName string)

Documentation

Index

Constants

View Source
const (
	Config  folderType = 0
	Cache   folderType = 1
	AppData folderType = 2
)

Variables

This section is empty.

Functions

func Register

func Register(packageName string)

Types

type IOComponent

type IOComponent struct {
	// contains filtered or unexported fields
}

func (*IOComponent) CreateFile

func (io *IOComponent) CreateFile(ft folderType, fileName string)

func (*IOComponent) IsExist

func (io *IOComponent) IsExist(ft folderType, fileName string) bool

func (*IOComponent) Mkdir

func (io *IOComponent) Mkdir(ft folderType, folder string) error

func (*IOComponent) ReadFromFile

func (io *IOComponent) ReadFromFile(ft folderType, fileName string) string

func (*IOComponent) RemoveFile

func (io *IOComponent) RemoveFile(ft folderType, fileName string)

func (*IOComponent) SetPackageName

func (io *IOComponent) SetPackageName(packageName string)

func (*IOComponent) WriteToFile

func (io *IOComponent) WriteToFile(ft folderType, fileName string, text string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL