/// <summary>
        /// Validate database directory.
        /// This method will try to create database directory if "CreateDatabase" option is set tot true.
        /// </summary>
        /// <returns>Success when directory exists, otherwise false</returns>
        protected virtual bool InitializeDatabasePaths()
        {
            if (!Configuration.Enabled)
            {
                return(false);
            }
            DatabasePath = Configuration.GetFullDatabasePath();
            if (string.IsNullOrEmpty(DatabasePath))
            {
                Debug.LogWarning("Backtrace database path is empty.");
                return(false);
            }

            var databaseDirExists = Directory.Exists(DatabasePath);

            // handle situation when Backtrace plugin should create database directory
            if (!databaseDirExists && Configuration.CreateDatabase)
            {
                var dirInfo = Directory.CreateDirectory(DatabasePath);
                databaseDirExists = dirInfo.Exists;
            }

            if (!databaseDirExists)
            {
                Debug.LogWarning(string.Format("Backtrace database path doesn't exist. Database path: {0}", DatabasePath));
            }
            return(databaseDirExists);
        }
Esempio n. 2
0
        /// <summary>
        /// Validate database directory.
        /// This method will try to create database directory if "CreateDatabase" option is set tot true.
        /// </summary>
        /// <returns>Success when directory exists, otherwise false</returns>
        protected virtual bool InitializeDatabasePaths()
        {
            if (!Configuration.Enabled)
            {
                return(false);
            }
            DatabasePath = Configuration.GetFullDatabasePath();
            if (string.IsNullOrEmpty(DatabasePath))
            {
                return(false);
            }

            var databaseDirExists = Directory.Exists(DatabasePath);

            // handle situation when Backtrace plugin should create database directory
            if (!databaseDirExists && Configuration.CreateDatabase)
            {
                var dirInfo = Directory.CreateDirectory(DatabasePath);
                databaseDirExists = dirInfo.Exists;
            }

            return(databaseDirExists);
        }
Esempio n. 3
0
    /// <summary>
    /// Full options constructor.
    /// </summary>
    /// <param name="backtraceConfiguration">BacktraceConfiguration</param>
    /// <param name="autowrite">Whether or not to spawn a background thread to write new breadcrumbs to disk</param>
    /// <param name="millisWaitBeforeWrite">How many millis to wait before spawning a write thread</param>
    /// <param name="backtraceConfiguration">BacktraceConfiguration</param>
    /// <returns>BreadcrumbsWriter</returns>
    public BreadcrumbsWriter(BacktraceConfiguration backtraceConfiguration, bool autowrite, int millisWaitBeforeWrite, long maxFileSize)
    {
        this.waitBeforeWrite = millisWaitBeforeWrite;
        this.autoWrite       = autowrite;
        this.maxFileSize     = maxFileSize;
        string breadcrumbsDir = backtraceConfiguration.GetFullDatabasePath() + BREADCRUMBS_DIRNAME;

        if (!Directory.Exists(breadcrumbsDir))
        {
            Directory.CreateDirectory(breadcrumbsDir);
        }

        breadcrumbsFilePath = breadcrumbsDir + Path.DirectorySeparatorChar + BREADCRUMB_FILENAME;
        if (File.Exists(breadcrumbsFilePath))
        {
            breadcrumbsByteSize = new FileInfo(breadcrumbsFilePath).Length;
            breadcrumbs         = new LinkedList <string>(File.ReadAllLines(breadcrumbsFilePath));
        }
        else
        {
            breadcrumbs = new LinkedList <string>();
        }
    }