Exemple #1
0
        public bool Save(string targetLocation)
        {
            if (!SysUtil.InTheSameDrive(GState.AssetRoot, targetLocation))
            {
                Logging.Instance.Log("将要保存的 {0} 文件与资源路径不在同一个分区,无法使用相对路径。", ConstDefault.LayoutPostfix);
                Logging.Instance.Log("    请将 {0} 文件保存到分区 {1}。", ConstDefault.LayoutPostfix, Path.GetPathRoot(GState.AssetRoot));
                Logging.Instance.Log("    目标路径:{0}", targetLocation);
                Logging.Instance.Log("    资源路径:{1}", GState.AssetRoot);
                return(false);
            }

            string folderPath = Path.GetDirectoryName(targetLocation);

            m_root.Assets.AssetRoot = SysUtil.ToUnixPath(SysUtil.GetRelativePath(GState.AssetRoot, folderPath));

            if (!m_archiveSys.Save(m_root, targetLocation))
            {
                m_root.Assets.AssetRoot = GState.AssetRoot;
                return(false);
            }

            if (m_currentFilePath != targetLocation)
            {
                m_currentFilePath = targetLocation;
            }
            return(true);
        }
Exemple #2
0
        public static string ComposeSingleTextureURL(string singleTexturePath)
        {
            //      '\\abc\\foo\\'
            //      会被转为
            //      'abc/foo'
            string unixStyle = SysUtil.ToUnixPath(SysUtil.TrimHeadTailSeparators(singleTexturePath));

            return(ComposeURL(unixStyle, ResProtocol.TileSingleTextureMarker));
        }
Exemple #3
0
        public static AssetDesc CreateDesc(string assetPath)
        {
            string unixStyle = SysUtil.ToUnixPath(SysUtil.TrimHeadTailSeparators(assetPath));
            string filename  = Path.GetFileNameWithoutExtension(unixStyle);
            string ext       = Path.GetExtension(unixStyle);

            if (string.IsNullOrEmpty(filename))
            {
                Logging.Instance.Log("CreateDesc() failed (invalid asset path): {0}.", assetPath);
                return(null);
            }

            string fullpath = Path.Combine(GState.AssetRoot, SysUtil.ToWindowsPath(unixStyle));

            if (!File.Exists(fullpath))
            {
                Logging.Instance.Log("CreateDesc() failed (file not found): {0}.", assetPath);
                return(null);
            }

            string digest = SysUtil.GetFileMD5AsString(fullpath);

            if (string.IsNullOrEmpty(digest))
            {
                Logging.Instance.Log("CreateDesc() failed (md5 calculating failed): {0}.", fullpath);
                return(null);
            }

            AssetType type = AssetType.Unknown;

            if (ext.ToLower() == "png")
            {
                type = AssetType.PNG;
            }

            AssetDesc desc = new AssetDesc();

            desc.LinkTime = DateTime.Now;
            desc.Name     = filename + "_" + desc.LinkTime.ToString("yyyyMMdd_HHmmss");
            desc.Type     = type;
            desc.Path     = unixStyle;
            desc.Digest   = digest;
            return(desc);
        }