public void FromAbsoluteFilePathDeepTest() { var n = ContentAssetName.FromAbsoluteFilePath(@"C:\whatever\path\to\mycontent\is\super\awesome", @"C:\whatever\path\to"); Assert.AreEqual(@"mycontent\is\super\awesome".Replace("\\", ContentAssetName.PathSeparator), n.Value); }
public void FromAbsoluteFilePathWithSuffixTest() { var n = ContentAssetName.FromAbsoluteFilePath(@"C:\whatever\path\to\mycontent" + ContentPaths.ContentFileSuffix, @"C:\whatever\path\to"); Assert.AreEqual("mycontent", n.Value); }
public void FromAbsoluteFilePathAlternateSeparatorDeepTest() { var n = ContentAssetName.FromAbsoluteFilePath(@"C:/whatever/path/to/mycontent/is/super/awesome", @"C:/whatever/path/to"); Assert.AreEqual(@"mycontent/is/super/awesome".Replace("/", ContentAssetName.PathSeparator), n.Value); }
/// <summary> /// Creates the <see cref="StationaryGrhData"/> frames for this <see cref="AutomaticAnimatedGrhData"/>. /// </summary> /// <param name="directory">The directory containing the frames.</param> /// <returns>An array of the <see cref="StationaryGrhData"/> frames.</returns> StationaryGrhData[] CreateFrames(string directory) { // Find all the valid content files var allFiles = Directory.GetFiles(directory, "*" + ContentPaths.ContentFileSuffix, SearchOption.TopDirectoryOnly); // Filter out the files with invalid naming conventions, and sort them so we animate in the correct order var files = SortAndFilterFrameFiles(allFiles); // Build the individual frames var frames = new StationaryGrhData[files.Length]; for (var i = 0; i < frames.Length; i++) { var contentAssetName = ContentAssetName.FromAbsoluteFilePath(files[i], ContentPaths.Build.Grhs).Value; var textureAssetName = new TextureAssetName(contentAssetName); var frameGrhData = new StationaryGrhData(this, textureAssetName); frames[i] = frameGrhData; } if (frames.Length == 0) { throw new Exception("Animation has no frames"); } return(frames); }
public void FromAbsoluteFilePathWithSuffixCapsTest() { var n = ContentAssetName.FromAbsoluteFilePath( (@"C:\whatever\path\to\mycontent" + ContentPaths.ContentFileSuffix).ToUpper(), @"C:\whatever\path\to"); Assert.AreEqual("mycontent", n.Value.ToLower()); }
/// <summary> /// Updates the HashInfo for all of the files in the specified root directory. /// </summary> void UpdateHashes() { var files = GetFilesToHash(_rootTextureDir); foreach (var file in files) { try { // Get the current info var contentAssetName = ContentAssetName.FromAbsoluteFilePath(file, _rootTextureDir).Value; var textureName = new TextureAssetName(contentAssetName).Value; HashInfo hashInfo = null; if (Contains(textureName)) { hashInfo = this[textureName]; } // Get the file size and last modified time int size; long lastMod; GetFileSizeAndLastModified(file, out size, out lastMod); // If we already have the hash info, and the size and last modified time have not changed, // we can skip updating the hash if (hashInfo != null && hashInfo.FileSize == size && hashInfo.LastModifiedTime == lastMod) { continue; } // Get the new hash and add the new file or update the existing values var hash = GetFileHash(file); if (hashInfo == null) { hashInfo = new HashInfo(hash, size, lastMod); this[textureName] = hashInfo; } else { hashInfo.FileSize = size; hashInfo.Hash = hash; hashInfo.LastModifiedTime = lastMod; } } catch (IOException) { } catch (UnauthorizedAccessException) { } } // Write the updates Save(); }
public void FromAbsoluteFilePathTrailingSlashTest() { var n = ContentAssetName.FromAbsoluteFilePath(@"C:\whatever\path\to\mycontent", @"C:\whatever\path\to\"); Assert.AreEqual("mycontent", n.Value); }
public void FromAbsoluteFilePathCapsTest() { var n = ContentAssetName.FromAbsoluteFilePath(@"C:\whatever\path\to\mycontent".ToUpper(), @"C:\whatever\path\to"); Assert.AreEqual("mycontent", n.Value.ToLower()); }
public void FromAbsoluteFilePathAlternateSeparatorTest() { var n = ContentAssetName.FromAbsoluteFilePath(@"C:/whatever/path/to/mycontent", @"C:/whatever/path/to"); Assert.AreEqual("mycontent", n.Value); }