Created
June 3, 2012 19:11
-
-
Save jcanfield/2864679 to your computer and use it in GitHub Desktop.
Create Hardlinks to Sync Folders with Google Drive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
Synopsis: One of two viable options I have found to create hard-links of directories from other directories on your system directly to Google Drive has been hardlink.c (by Sam, @selkhateeb on Github) and a Mac OSX Application called SymbolicLinker. SymbolicLinker can be found at http://seiryu.home.comcast.net/~seiryu/symboliclinker.html as-well as http://www.macupdate.com/app/mac/10433/symboliclinker. Now, you can sync specific folders to your Google Drive since that GDrive does not allow for actual symbolic links (ln -s) to create files that will be uploaded to the "cloud". | |
Application: hardlink | |
URL: https://github.com/selkhateeb/hardlink | |
Author: Sam (@selkhateeb) | |
Description: Allows for the user to create hardlinks of directories. | |
Installation: 1) make 2) sudo make install | |
Usage: hardlink /home/username/foldername/ /home/username/Documents/Cloud/foldername/ | |
***/ | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <string.h> | |
/* | |
On Mac OSX, we can't create hard links using the ln command.. | |
Install: | |
make | |
sudo make install | |
*/ | |
int main(int argc, char* argv[]) { | |
//Make sure we have the right arguments | |
if (argc != 3) | |
{ | |
fprintf(stderr,"Usage:\thardlink source destination\n"); | |
fprintf(stderr,"\t hard links the source directory to the destination\n"); | |
fprintf(stderr,"\thardlink -u destination\n"); | |
fprintf(stderr,"\t unlinks the destination directoy\n"); | |
return 1; | |
} | |
int ret = 0; | |
if(strcmp(argv[1], "-u") == 0) | |
{ | |
ret = unlink(argv[2]); | |
} | |
else | |
ret = link(argv[1],argv[2]); | |
if (ret != 0) | |
perror("hardlink"); | |
return ret; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OUTPUT=hardlink | |
C_FILES=hardlink.c | |
all: | |
gcc ${C_FILES} -o ${OUTPUT} | |
clean: | |
rm ${OUTPUT} | |
install: | |
cp ${OUTPUT} /usr/local/bin/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! As an alternative, you can also install the GNU
coreutils
and usegln -d
: