Вобщем понадобилось иметь один проект в двух репозиториях. svn:externals использовать было нельзя. На синхронность ревизий было глубоко наплевать. А вот править одни и те же файлы по два раза не хотелось. В результате родилось вот это.
using System;
using System.Runtime.InteropServices;
using System.IO;
namespace DeepHardLink
{
class Program
{
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern bool CreateHardLink(string pathDestination, string pathSource, IntPtr lpSecurityAttributes);
static int rootLength = 0;
static void DeepCopy(string pathSource, string pathDestination)
{
DirectoryInfo dirInfoSource = new DirectoryInfo(pathSource);
DirectoryInfo dirInfoDestination = new DirectoryInfo(pathDestination);
foreach (DirectoryInfo dirInfo in dirInfoSource.GetDirectories())
{
if (!dirInfo.Name.StartsWith(".svn"))
{
string subPathSource = pathSource + "\\" + dirInfo.Name;
string subPathDestination = pathDestination + "\\" + dirInfo.Name;
if (!Directory.Exists(subPathDestination))
{
Directory.CreateDirectory(subPathDestination);
}
DeepCopy(subPathSource, subPathDestination);
}
}
foreach (FileInfo fileInfo in dirInfoSource.GetFiles())
{
string subPathSource = pathSource + "\\" + fileInfo.Name;
string subPathDestination = pathDestination + "\\" + fileInfo.Name;
if (!File.Exists(subPathDestination))
{
if (CreateHardLink(subPathDestination, subPathSource, IntPtr.Zero))
{
Console.WriteLine("OK: \"{0}\"", subPathSource.Substring(rootLength));
}
else
{
Console.WriteLine("FAILED: \"{0}\"", subPathSource.Substring(rootLength));
}
}
else
{
Console.WriteLine("SKIPED: \"{0}\"", subPathSource.Substring(rootLength));
}
}
}
static void Main(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine("Usage: DeepHardLink.exe source\\dir destination\\dir");
}
else
{
rootLength = args[0].Length;
DeepCopy(args[0], args[1]);
}
}
}
}
Кто считает, что я поступил неправильно идите в лес
Остальмым приятного просмотра.
Здравствуйте, adontz, Вы писали:
A>Кто считает, что я поступил неправильно идите в лес Остальмым приятного просмотра.
Да нет, вполне такой приличный велосипед. Ничем не лучше Alt+F6 в FAR'е
или отдельной прогой:
http://www.sysinternals.com/Utilities/Junction.html
а для любителей GUI'я:
http://rsdn.ru/Forum/Message.aspx?mid=1697711Автор: Nazik
Дата: 24.02.06
... << RSDN@Home 1.2.0 alpha rev. 642>>
Здравствуйте, Блудов Павел, Вы писали:
БП>Да нет, вполне такой приличный велосипед. Ничем не лучше Alt+F6 в FAR'е
Нуу это же замаешься на каждый файл-то
БП>или отдельной прогой: http://www.sysinternals.com/Utilities/Junction.html
БП>а для любителей GUI'я: http://rsdn.ru/Forum/Message.aspx?mid=1697711Автор: Nazik
Дата: 24.02.06
У меня велосипед специализированный
Вообще иммет смысл переделать так.
static void Main(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine("Usage: DeepHardLink.exe source\\dir destination\\dir");
}
else
{
rootLength = args[0].Length;
DeepCopy(args[0], args[1]);
rootLength = args[1].Length;
DeepCopy(args[1], args[0]);
}
}
Тогда синхронизация выйдет