Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB

  1. #!/usr/bin/perl -w
  2. use Data::Dumper;
  3. use FindBin;
  4. use Cwd qw(getcwd abs_path);
  5. use File::Basename;
  6. use lib "$FindBin::Bin/../devtools/lib";
  7. use P4Run;
  8. use strict;
  9. die "Usage: $0 <file>\n" unless @ARGV;
  10. my $path = shift @ARGV;
  11. my $dir = abs_path(dirname($path));
  12. my $file = "$dir/".basename($path);
  13. if ($ENV{VALVE_NO_AUTO_P4})
  14. {
  15. print "VALVE_NO_AUTO_P4 Set. Making $file writable\n";
  16. if ($^O eq 'MSWin32')
  17. {
  18. system('attrib', '-r', $file);
  19. }
  20. else
  21. {
  22. open(my $fh, "<", $file);
  23. my $perm = (stat($fh))[2] | 0220;
  24. chmod $perm, $fh;
  25. }
  26. }
  27. else
  28. {
  29. my $desc = $^O eq 'MSWin32' ? 'Visual Studio Auto Checkout' : 'GCC Auto Checkout';
  30. $desc = '360 Visual Studio Auto Checkout' if $file =~ /_360|launcher_main|default.xex/;
  31. my $change = P4Run::FindChange($desc) || P4Run::NewChange($desc);
  32. die "Failed to create Change List: $desc\n" unless $change;
  33. my ($stat) = P4Run('fstat', $file);
  34. if ($stat)
  35. {
  36. print "Opening $file for edit in CL#$change ($desc)\n";
  37. P4Run('edit', '-c', $change, $file);
  38. }
  39. else
  40. {
  41. print "Adding new file $file to CL#$change ($desc)\n";
  42. open(my $fh, ">", $file); close($fh);
  43. P4Run('add', '-c', $change, '-t', 'xbinary', $file);
  44. unlink($file);
  45. }
  46. }
  47. warn "$file is not writable\n" if (-e $file && ! -w $file);
  48. exit 0;