예제 #1
0
        /// <summary>
        /// Deserialize the dependency cache from a binary reader
        /// </summary>
        /// <param name="Reader">Reader for the cache data</param>
        /// <returns>New dependency cache object</returns>
        static DependencyCache Deserialize(BinaryReader Reader)
        {
            DependencyCache Cache = new DependencyCache(Reader.ReadFileReference());

            Cache.CreationTimeUtc = DateTime.FromBinary(Reader.ReadInt64());

            int NumEntries = Reader.ReadInt32();

            Cache.DependencyMap = new Dictionary <FileReference, List <DependencyInclude> >(NumEntries);

            List <FileReference> UniqueFiles = new List <FileReference>();

            for (int Idx = 0; Idx < NumEntries; Idx++)
            {
                FileReference File = Reader.ReadFileReference();

                int NumIncludes = Reader.ReadInt32();
                List <DependencyInclude> Includes = new List <DependencyInclude>(NumIncludes);

                for (int IncludeIdx = 0; IncludeIdx < NumIncludes; IncludeIdx++)
                {
                    DependencyInclude Include = new DependencyInclude(Reader.ReadString());
                    Include.HasAttemptedResolve             = Reader.ReadBoolean();
                    Include.IncludeResolvedNameIfSuccessful = Reader.ReadFileReference(UniqueFiles);
                    Includes.Add(Include);
                }

                Cache.DependencyMap.Add(File, Includes);
            }

            Cache.CreateFileExistsInfo();
            Cache.ResetUnresolvedDependencies();
            return(Cache);
        }
예제 #2
0
        /**
         * Loads the cache from the passed in file.
         *
         * @param	Cache	File to deserialize from
         */
        public static DependencyCache Load(FileItem Cache)
        {
            DependencyCache Result = null;

            try
            {
                using (FileStream Stream = new FileStream(Cache.AbsolutePath, FileMode.Open, FileAccess.Read))
                {
                    BinaryFormatter Formatter = new BinaryFormatter();
                    Result = Formatter.Deserialize(Stream) as DependencyCache;
                }
                Result.CreateFileExistsInfo();
                Result.ResetUnresolvedDependencies();
            }
            catch (Exception Ex)
            {
                // Don't bother logging this expected error.
                // It's due to a change in the CacheCreateDate type.
                if (Ex.Message != "Object of type 'System.DateTime' cannot be converted to type 'System.DateTimeOffset'" &&
                    Ex.Message != "Object of type 'System.Collections.Generic.Dictionary`2[System.String,System.Collections.Generic.List`1[System.String]]' cannot be converted to type 'System.Collections.Generic.Dictionary`2[System.String,UnrealBuildTool.DependencyInfo]'.") // To catch serialization differences added when we added the DependencyInfo struct
                {
                    Console.Error.WriteLine("Failed to read dependency cache: {0}", Ex.Message);
                }
            }
            return(Result);
        }
예제 #3
0
        /**
         * Loads the cache from the passed in file.
         *
         * @param	Cache	File to deserialize from
         */
        public static DependencyCache Load(FileItem Cache)
        {
            DependencyCache Result = null;

            try
            {
                string CacheBuildMutexPath = Cache.AbsolutePath + ".buildmutex";

                // If the .buildmutex file for the cache is present, it means that something went wrong between loading
                // and saving the cache last time (most likely the UBT process being terminated), so we don't want to load
                // it.
                if (!File.Exists(CacheBuildMutexPath))
                {
                    using (File.Create(CacheBuildMutexPath))
                    {
                    }

                    using (FileStream Stream = new FileStream(Cache.AbsolutePath, FileMode.Open, FileAccess.Read))
                    {
                        BinaryFormatter Formatter = new BinaryFormatter();
                        Result = Formatter.Deserialize(Stream) as DependencyCache;
                    }
                    Result.CreateFileExistsInfo();
                    Result.ResetUnresolvedDependencies();
                }
            }
            catch (Exception Ex)
            {
                // Don't bother logging this expected error.
                // It's due to a change in the CacheCreateDate type.
                if (Ex.Message != "Object of type 'System.DateTime' cannot be converted to type 'System.DateTimeOffset'" &&
                    Ex.Message != "Object of type 'System.Collections.Generic.Dictionary`2[System.String,System.Collections.Generic.List`1[System.String]]' cannot be converted to type 'System.Collections.Generic.Dictionary`2[System.String,UnrealBuildTool.DependencyInfo]'.") // To catch serialization differences added when we added the DependencyInfo struct
                {
                    Console.Error.WriteLine("Failed to read dependency cache: {0}", Ex.Message);
                }
            }
            return(Result);
        }
		/// <summary>
		/// Deserialize the dependency cache from a binary reader
		/// </summary>
		/// <param name="Reader">Reader for the cache data</param>
		/// <returns>New dependency cache object</returns>
		static DependencyCache Deserialize(BinaryReader Reader)
		{
			DependencyCache Cache = new DependencyCache(Reader.ReadFileReference());
			Cache.CreationTimeUtc = DateTime.FromBinary(Reader.ReadInt64());

			int NumEntries = Reader.ReadInt32();
			Cache.DependencyMap = new Dictionary<FileReference, List<DependencyInclude>>(NumEntries);

			List<FileReference> UniqueFiles = new List<FileReference>();
			for (int Idx = 0; Idx < NumEntries; Idx++)
			{
				FileReference File = Reader.ReadFileReference();

				int NumIncludes = Reader.ReadInt32();
				List<DependencyInclude> Includes = new List<DependencyInclude>(NumIncludes);

				for (int IncludeIdx = 0; IncludeIdx < NumIncludes; IncludeIdx++)
				{
					DependencyInclude Include = new DependencyInclude(Reader.ReadString());
					Include.HasAttemptedResolve = Reader.ReadBoolean();
					Include.IncludeResolvedNameIfSuccessful = Reader.ReadFileReference(UniqueFiles);
					Includes.Add(Include);
				}

				Cache.DependencyMap.Add(File, Includes);
			}

			Cache.CreateFileExistsInfo();
			Cache.ResetUnresolvedDependencies();
			return Cache;
		}