Esempio n. 1
0
        public void CalcNewPathAndID(EpubItem item, int offset)
        {
            string oldAbsolutePath = item.AbsolutePath;
            var    oldFileName     = oldAbsolutePath.getZipFileName();
            var    oldprefix       = EpubItem.PrefixAsInt(oldFileName);
            var    fileName        = oldFileName.StripPrefixFromFileName();
            var    path            = oldAbsolutePath.GetZipPath();

            if (!string.IsNullOrEmpty(path))
            {
                path += '/';
            }

            // note possible conflict as "cover" does not have a prefix
            // which might conflict if there was also a page with 0000_cover.xhtml
            // So, if page has a prefix, bump offest by one.
            var bump = EpubItem.ExtractPrefixFromFileName(oldFileName) == null ? 0 : 1;

            var newPrefix       = (oldprefix + offset + bump).ToString("D4");
            var newAbsolutePath = $"{path}{newPrefix}_{fileName}";

            NewAbsolutePaths.Add(oldAbsolutePath, newAbsolutePath);

            string newId = item.Id.StripDigits() + newPrefix;

            NewItemIds.Add(item.Id, newId);
        }