Bloom.Book.BookMetaData.FromFolder C# (CSharp) Method

FromFolder() public static method

public static FromFolder ( string bookFolderPath ) : BookMetaData
bookFolderPath string
return BookMetaData
        public static BookMetaData FromFolder(string bookFolderPath)
        {
            return FromString(RobustFile.ReadAllText(MetaDataPath(bookFolderPath)));
        }

Usage Example

Example #1
0
        public BookInfo(string folderPath, bool isEditable)
        {
            FolderPath = folderPath;

            //NB: This was coded in an unfortunate way such that touching almost any property causes a new metadata to be quietly created.
            //So It's vital that we not touch properties that could create a blank metadata, before attempting to load the existing one.

            _metadata = BookMetaData.FromFolder(FolderPath);
            if (_metadata == null)
            {
                // Look for old tags files not yet migrated
                var oldTagsPath = Path.Combine(folderPath, "tags.txt");
                if (RobustFile.Exists(oldTagsPath))
                {
                    Book.ConvertTagsToMetaData(oldTagsPath, this);
                }
                // otherwise leave it null, first attempt to use will create a default one
            }

            IsEditable = isEditable;

            FixDefaultsIfAppropriate();
        }