env

package
v0.0.0-...-ed12b99 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

env will control the filesystem environment

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDatabase

func CreateDatabase(RunningConfig *Config) *sql.DB

func CreateDir

func CreateDir(pathroot string) (string, string)

CreateDir will create the folder sturcture for the AniBD program to run properly. Input: pathroot is a string that describes where the root folder for the program should be. Output: programpath is a string that will be the base folder used to store anime eppisodes and cache AniDB data. Output: configpath is a string that will be the base folder used to store configuration data. Errors: Any errors created will be related to the filesystem and whether or not directories were created. Process: CreateDir takes the pathroot input and creates the necessary directores for golanganidb. If the directories already exist, they are not recreated.

func GetHomeDir

func GetHomeDir() string

GetHomeDir will return the home directory for the user executing the program. Output: The full path of the user's home directory. Errors: Any errors generated while accessing the user information. Process: Get user information and return the home directory

func WriteConfig

func WriteConfig(configfile string, configstruct *Config)

CreateConfig will take a Config struct and write it to disk. Input: configfile is a string that points to the location on disk for the configuration file. Input: configstruct points to a Config struct to write to disk. Output: Configuration file is written to disk Error: Errors returned will be related to creating the file on the OS. If the configuration file cannot be written, changes made while the program is running will not be saved Process: Created the configuration file and write the Config struct to disk.

Types

type Config

type Config struct {
	Client            string               //The registered name of the client on the AniDB API.
	Clientver         int                  //The registered version of the client on the AniDB API.
	Protover          int                  //The version of the AniDB API to use.
	Url               string               //The URL for the AniDB API.
	Port              int                  //Port number used to connect to the AniDB API.
	ProgramDataPath   string               //Path where Anime and Episodes will be stored
	ProgramConfigPath string               //Path for all other data
	Provider          []newznabapi.Newznab //Newznab provides config data
}

Config is a struct that contains the configuration information.

func SetupEnv

func SetupEnv() (*Config, *sql.DB)

SetupEnv controls and/or creates the environment for the program Input: programRootPath is a string stating the root path for the program. Defaults to user's home directory Input: configurationFilePtr is a string stating the path to the configuration file. Defaults to user's home directory .golanganidb/golanganidb.conf. Outputs: retuns a Config struct with the current configuration. Errors: errors will come from env functions. Process: Create a new Config struct. Check to see if a configuration file already exists. If no configuration file exists, then complete the Config struct with default paramerers and write the configuration file to disk. If a configuration file does exist, then read its contents into the Config struct.

func (*Config) ReadConfig

func (configstruct *Config) ReadConfig(configfile string) *Config

ReadConfig will turn an existing configuration file into a Config struct. Input: configfile is a sting that points to an existing configuration file. Ouptput: A struct of type Config Error: An error is returned if the existing configuration file cannot be read. Process: Read the existing configuration file as a byte. Create a new Config struct. Split the byte file into lines and pass to the configtostruct function.

Jump to

Keyboard shortcuts

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