コード例 #1
0
        private static bool IsValidFilePath(BackupMetadata meta)
        {
            if (BackupFileTools.IsUrl(meta.PhysicalDeviceName))
            {
                return(true);
            }

            // A quick check before leaning on exceptions
            if (Path.GetInvalidPathChars().Any(meta.PhysicalDeviceName.Contains))
            {
                return(false);
            }

            try {
                // This will throw an argument exception if the path is invalid
                Path.GetFullPath(meta.PhysicalDeviceName);
                // A relative path won't help us much if the destination is another server. It needs to be rooted.
                return(Path.IsPathRooted(meta.PhysicalDeviceName));
            }
            catch (Exception) {
                return(false);
            }
        }
コード例 #2
0
        private static bool IsValidFilePath(BackupMetadata meta)
        {
            var path = meta.PhysicalDeviceName;

            return(BackupFileTools.IsValidFileUrl(path) || BackupFileTools.IsValidFilePath(path));
        }
コード例 #3
0
 public void InValidPathTests(string path)
 {
     Assert.False(BackupFileTools.IsValidFilePath(path));
 }
コード例 #4
0
 public void BackupTypeAbbrevToType(string abbrev, BackupFileTools.BackupType type)
 {
     Assert.Equal(type, BackupFileTools.BackupTypeAbbrevToType(abbrev));
 }
コード例 #5
0
 public void BackupTypeToExtensionTest(BackupFileTools.BackupType type, string ext)
 {
     Assert.Equal(ext, BackupFileTools.BackupTypeToExtension(type));
 }
コード例 #6
0
 public void InvalidUrlTests(string url)
 {
     Assert.False(BackupFileTools.IsValidFileUrl(url));
 }
コード例 #7
0
 public void ValidUrlTests(string url)
 {
     Assert.True(BackupFileTools.IsValidFileUrl(url));
 }
コード例 #8
0
 public void NonUrlFilesAreNotUrl(string file)
 {
     Assert.False(BackupFileTools.IsUrl(file));
 }
コード例 #9
0
 public void UrlFilesAreUrl(string file)
 {
     Assert.True(BackupFileTools.IsUrl(file));
 }