rmcvsdir.pp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {
  2. Copyright (c) 1999-2012 by Marco van de Voort and Free Pascal Core
  3. Recursively deletes .cvs and .svn directories essentially "exporting" a
  4. repository in place. Typically used when cleaning out old checkouts, to
  5. prepare for a GNU diff session with another checkout.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. }
  18. program rmcvsdir;
  19. uses
  20. sysutils;
  21. procedure deltree(const dirname : string);
  22. var
  23. rec : tsearchrec;
  24. begin
  25. writeln('Deleting ',dirname);
  26. if findfirst(dirname+'/*.*',faanyfile or fadirectory,rec)=0 then
  27. begin
  28. repeat
  29. if (rec.attr and fadirectory)<>0 then
  30. begin
  31. if (rec.name<>'.') and (rec.name<>'..') then
  32. deltree(dirname+'/'+rec.name)
  33. end
  34. else
  35. begin
  36. FileSetAttr(dirname+'/'+rec.name,faArchive);
  37. deletefile(dirname+'/'+rec.name);
  38. end;
  39. until findnext(rec)<>0;
  40. findclose(rec);
  41. end;
  42. rmdir(dirname);
  43. end;
  44. procedure searchcvsdir(const dirname : string);
  45. var
  46. rec : tsearchrec;
  47. begin
  48. writeln('Searching ',dirname);
  49. if findfirst(dirname+'/*.*',faanyfile or fadirectory,rec)=0 then
  50. begin
  51. repeat
  52. if (rec.attr and fadirectory)<>0 then
  53. begin
  54. if rec.name='CVS' then
  55. deltree(dirname+'/CVS')
  56. else if rec.name='.svn' then
  57. deltree(dirname+'/.svn')
  58. else
  59. if (rec.name<>'.') and (rec.name<>'..') then
  60. searchcvsdir(dirname+'/'+rec.name)
  61. end;
  62. until findnext(rec)<>0;
  63. findclose(rec);
  64. end;
  65. end;
  66. var
  67. para : string;
  68. begin
  69. if paramcount=0 then
  70. para:='.'
  71. else
  72. para:=paramstr(1);
  73. searchcvsdir(para);
  74. end.