예제 #1
0
 bool WriteVersionFile(PerforceWhereRecord WhereRecord, string NewText)
 {
     try
     {
         if (File.Exists(WhereRecord.LocalPath) && File.ReadAllText(WhereRecord.LocalPath) == NewText)
         {
             Log.WriteLine("Ignored {0}; contents haven't changed", WhereRecord.LocalPath);
         }
         else
         {
             Utility.ForceDeleteFile(WhereRecord.LocalPath);
             if (WhereRecord.DepotPath != null)
             {
                 Perforce.Sync(WhereRecord.DepotPath + "#0", Log);
             }
             File.WriteAllText(WhereRecord.LocalPath, NewText);
             Log.WriteLine("Written {0}", WhereRecord.LocalPath);
         }
         return(true);
     }
     catch (Exception Ex)
     {
         Log.WriteException(Ex, "Failed to write to {0}.", WhereRecord.LocalPath);
         return(false);
     }
 }
예제 #2
0
        public bool Where(string Filter, out PerforceWhereRecord WhereRecord, TextWriter Log)
        {
            List <PerforceFileRecord> FileRecords;

            if (!RunCommand(String.Format("where \"{0}\"", Filter), out FileRecords, CommandOptions.None, Log))
            {
                WhereRecord = null;
                return(false);
            }

            FileRecords.RemoveAll(x => x.Unmap);

            if (FileRecords.Count == 0)
            {
                Log.WriteLine("'{0}' is not mapped to workspace.", Filter);
                WhereRecord = null;
                return(false);
            }
            else if (FileRecords.Count > 1)
            {
                Log.WriteLine("File is mapped to {0} locations: {1}", FileRecords.Count, String.Join(", ", FileRecords.Select(x => x.Path)));
                WhereRecord = null;
                return(false);
            }

            WhereRecord            = new PerforceWhereRecord();
            WhereRecord.LocalPath  = FileRecords[0].Path;
            WhereRecord.DepotPath  = FileRecords[0].DepotPath;
            WhereRecord.ClientPath = FileRecords[0].ClientPath;
            return(true);
        }
예제 #3
0
		bool WriteVersionFile(PerforceWhereRecord WhereRecord, string NewText)
		{
			try
			{
				if(File.Exists(WhereRecord.LocalPath) && File.ReadAllText(WhereRecord.LocalPath) == NewText)
				{
					Log.WriteLine("Ignored {0}; contents haven't changed", WhereRecord.LocalPath);
				}
				else
				{
					Utility.ForceDeleteFile(WhereRecord.LocalPath);
					if(WhereRecord.DepotPath != null)
					{
						Perforce.Sync(WhereRecord.DepotPath + "#0", Log);
					}
					File.WriteAllText(WhereRecord.LocalPath, NewText);
					Log.WriteLine("Written {0}", WhereRecord.LocalPath);
				}
				return true;
			}
			catch(Exception Ex)
			{
				Log.WriteException(Ex, "Failed to write to {0}.", WhereRecord.LocalPath);
				return false;
			}
		}
예제 #4
0
		public bool Where(string Filter, out PerforceWhereRecord WhereRecord, TextWriter Log)
		{
			List<PerforceFileRecord> FileRecords;
			if(!RunCommand(String.Format("where \"{0}\"", Filter), out FileRecords, CommandOptions.None, Log))
			{
				WhereRecord = null;
				return false;
			}

			FileRecords.RemoveAll(x => x.Unmap);

			if(FileRecords.Count == 0)
			{
				Log.WriteLine("'{0}' is not mapped to workspace.", Filter);
				WhereRecord = null;
				return false;
			}
			else if(FileRecords.Count > 1)
			{
				Log.WriteLine("File is mapped to {0} locations: {1}", FileRecords.Count, String.Join(", ", FileRecords.Select(x => x.Path)));
				WhereRecord = null;
				return false;
			}

			WhereRecord = new PerforceWhereRecord();
			WhereRecord.LocalPath = FileRecords[0].Path;
			WhereRecord.DepotPath = FileRecords[0].DepotPath;
			WhereRecord.ClientPath = FileRecords[0].ClientPath;
			return true;
		}