Home Page
  • April 25, 2024, 09:11:44 am *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Official site launch very soon, hurrah!



Post reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

Name:
Email:
Subject:
Message icon:

Attach:
(Clear Attachment)
(more attachments)
Restrictions: 10 per post, maximum total size 8192KB, maximum individual size 5120KB
Note that any files attached will not be displayed until approved by a moderator.
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
Please stop spamming. Your spam posts are moderated and will never be displayed on the internet. What is eighty-eight minus eighty-six (spell out the answer):
Пожалуйста, прекратите спамить. Ваши спам-сообщения модерируются и никогда не будут отображаться в Интернете. What color is grass.:

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: Dakusan
« on: January 03, 2011, 07:24:07 am »


Since I found out that NTFS now has semi-working native symlinks, I have updated the symlinking script used in the Combining an Android Project's Versions post. This script creates relative symlinks now through Perl instead of absolute hard links through Bash. It is as follows:


#!/usr/bin/perl
#Run this file to install links to shared files into all branches
use warnings;
use strict;

#Configuration
my $SharedDirectoryName="Shared";
my $NonProjectDirectories="^\\.(|/\\.git|/$SharedDirectoryName)\$"; #Non Project directories (., .git, $SharedDirectoryName)
my $IsWindows=(index(lc(`uname`), 'cygwin')!=-1);

#Create a symlink
sub MakeLink
{
   my ($LinkTarget, $LinkName, $IsWindows, $IsDirectory)=@_;

   #Create the target directory if it does not exist
   my $LinkDirectory=$LinkName;
   $LinkDirectory =~ s/\/[^\/]+$//;
   if(!-e $LinkDirectory) {
      print "Creating directory: $LinkDirectory\n";
      `mkdir -p "$LinkDirectory"`;
   }
   
   #If the link already exists, issue a warning
   if(-l $LinkName) {
      print "Link already exists: $LinkName\n";
      return;
   }

   #Create the relative symlink
   my $RelativePathFromLinkToTarget=('../' x ($LinkName =~ tr/\///)).$LinkTarget; #Determine the relative path between the link and its target
   my $Command;
   if(!$IsWindows) { #Create the Linux command
      $Command="ln -s \"$RelativePathFromLinkToTarget\" \"$LinkName\"";
   }
   else #Create the Windows command
   {
      #Replace /s in path with \s
      $RelativePathFromLinkToTarget =~ s/\//\\/g;
      $LinkName =~ s/\//\\/g;
      
      $Command='cmd /c mklink'.($IsDirectory ? ' /d' : '')." \"$LinkName\" \"$RelativePathFromLinkToTarget\"";
   }

   print "$Command\n";
   `$Command`;
}

#Find required information from file searches
my @LocalBranches=grep(!/$NonProjectDirectories/, `find -maxdepth 1 -type d`); #Find version folders by ignoring Non Project directories
my @Files=split(/\n?^$SharedDirectoryName\//m, substr(`find $SharedDirectoryName -type f`, 0, -1)); shift @Files; #Find shared files

#Propagate shared files into different versions
foreach my $LocalBranch (@LocalBranches) {
   $LocalBranch=substr($LocalBranch, 2, -1); #Remove ./ and new line separator
   foreach my $File (@Files) {
      MakeLink("$SharedDirectoryName/$File", "$LocalBranch/$File", $IsWindows, 0);
   }
}