Пример #1
0
        public static string GetTempDocsPathToNewFileSystemPath(ContentURI uri, bool isLocalCacheDirectory,
                                                                string newFileName)
        {
            //210 added specifically for script file handling (http to file server path conversions)
            string sTempDocPath = string.Empty;

            if (!string.IsNullOrEmpty(uri.URIDataManager.TempDocPath))
            {
                string sOldTempFileName = Path.GetFileName(uri.URIDataManager.TempDocPath);
                sTempDocPath = uri.URIDataManager.TempDocPath.Replace(sOldTempFileName, newFileName);
            }
            else
            {
                //make a new temp doc path for temp storage of script file
                string sDirectoryPath = GetTempWebDirectory(uri,
                                                            isLocalCacheDirectory, GeneralHelpers.Get2RandomInteger());
                string sDelimiter = FileStorageIO.GetDelimiterForFileStorage(sDirectoryPath);
                //make the tempdocpath
                string sTempDocPath2 = string.Concat(sDirectoryPath, sDelimiter, newFileName);
                //return sTempDocPath;
                bool bHasDirectory = FileStorageIO.DirectoryCreate(
                    uri, sTempDocPath2);
            }
            return(sTempDocPath);
        }
Пример #2
0
        public static string GetTempDocPath(ContentURI uri, bool isLocalCacheDirectory,
                                            string uriPattern, string tempURIPattern)
        {
            string sTempDocPath = string.Empty;
            //use uri.URIDataManager.TempDocURI to set subdirectory for holding
            //all related tempdocs (easy to package)
            string sRandomId  = ContentURI.GetURIPatternPart(tempURIPattern, ContentURI.URIPATTERNPART.id);
            string sNodeName  = ContentURI.GetURIPatternPart(tempURIPattern, ContentURI.URIPATTERNPART.node);
            string sDirectory = string.Empty;

            //ok to put empty uris in a "0" subfolder
            if (sRandomId != string.Empty &&
                sNodeName != GeneralHelpers.NONE &&
                sRandomId != "0")
            {
                //has a tempdoc to work with
                //uri.uridatamanager.tempdocuri's random urid is always subdir
                sDirectory = GetTempWebDirectory(uri, isLocalCacheDirectory,
                                                 GeneralHelpers.ConvertStringToInt(sRandomId));
            }
            else
            {
                //may be starting to build a tempdoc
                //need a random directory
                sDirectory = GetTempWebDirectory(uri, isLocalCacheDirectory,
                                                 GeneralHelpers.Get2RandomInteger());
            }
            string sDelimiter = FileStorageIO.GetDelimiterForFileStorage(sDirectory);
            //don't use uri.uriclubdocpath filename because it may not need to be set
            //for the selectedlinkedviewuri
            string sFileName = string.Concat(
                ContentHelper.MakeStandardFileNameFromURIPattern(uriPattern),
                GeneralHelpers.EXTENSION_XML);

            //make the tempdocpath
            sTempDocPath = string.Concat(sDirectory, sDelimiter,
                                         ContentHelper.MakeStandardFileNameFromURIPattern(uriPattern),
                                         GeneralHelpers.EXTENSION_XML);
            return(sTempDocPath);
        }
Пример #3
0
        public static string AddDirectoryToDirectoryPath(string fromDirectoryPath, string toDirectoryPath)
        {
            string sFullDirectoryPath = toDirectoryPath;

            //deal with when absoluteuripath ends with a delimiter or file name
            if (Path.HasExtension(toDirectoryPath))
            {
                sFullDirectoryPath = GetDirectoryName(toDirectoryPath);
            }
            char[] cDelimiter         = FileStorageIO.GetCDelimiterForFileStorage(fromDirectoryPath);
            string sDelimiter         = FileStorageIO.GetDelimiterForFileStorage(fromDirectoryPath);
            string sLastDirectoryName = string.Empty;

            if (fromDirectoryPath.EndsWith(sDelimiter))
            {
                sLastDirectoryName = GeneralHelpers.GetSubstringFromEnd(
                    fromDirectoryPath, cDelimiter, 2);
            }
            else
            {
                sLastDirectoryName = GeneralHelpers.GetSubstringFromEnd(
                    fromDirectoryPath, cDelimiter, 1);
            }
            string sToDelimiter            = FileStorageIO.GetDelimiterForFileStorage(toDirectoryPath);
            string sLastDirectoryDelimited = string.Concat(sToDelimiter,
                                                           sLastDirectoryName, sToDelimiter);

            if (!sFullDirectoryPath.EndsWith(sLastDirectoryDelimited))
            {
                sFullDirectoryPath = Path.Combine(sFullDirectoryPath, sLastDirectoryName);
                if (!sFullDirectoryPath.EndsWith(sToDelimiter))
                {
                    sFullDirectoryPath = string.Concat(sFullDirectoryPath, sToDelimiter);
                }
            }
            return(sFullDirectoryPath);
        }