-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitHubLocation.m
More file actions
75 lines (71 loc) · 2.85 KB
/
Copy pathGitHubLocation.m
File metadata and controls
75 lines (71 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
% DROPBOX Return root path of local Dropbox folder
% PATH = DROPBOX() returns the path.
% PATH = DROPBOX(RELATIVE) returns the full path to a file or folder
% relative to the root Dropbox path.
%
% DROPBOX keeps track of the location of your Dropbox folder across
% different machines and operating systems. On first-time use, it asks the
% user to locate the local Dropbox folder through a GUI window. The m-file
% then updates itself to recognize different machines through their
% hostname, so that only one copy of the file is needed (that you can keep
% in your Dropbox). DROPBOX does not rely on MATLAB preferences so it is
% robust across MATLAB versions and after fresh installs.
%
% Because the file edits itself, user changes are not recommended; the name
% of the file can be changed, however.
% DO NOT EDIT THIS FILE %
function p = GitHubLocation(varargin)
switch strtrim(evalc('system(''hostname'');'))
% Start hostname cases
case 'gruffalo'
p = fullfile('/home/gruffalo/',varargin{:});
case 'MobsEcolo'
p = fullfile('/home/greta',varargin{:});
case 'mobshamilton-HP-Z440-Workstation'
p = fullfile('/home/mobshamilton/Desktop/Alice/GitHub/',varargin{:});
case 'pinky'
p = fullfile('/home/pinky/Documents',varargin{:});
case 'mouse'
p = fullfile('/home/mickey/Documents/Theotime', varargin{:});
case 'ratatouille'
p = fullfile('/home/ratatouille/', varargin{:});
case 'pinky-VirtualBox'
p = fullfile('/media/sf_mickey/Documents/Theotime', varargin{:});
case 'mobs'
p = fullfile('/home/bernard/', varargin{:});
case 'LSPJR9SB74'
p = fullfile('D:\Arsenii\GitHub', varargin{:});
% End hostname cases
otherwise
dbdr = uigetdir(pwd,'Please locate your GitHub folder.');
if ~dbdr
error('GitHub:GitHub:folderNotFound',...
'Your GitHub folder could not be located.')
end
tempfile = tempname();
thisfile = which(mfilename);
fi = fopen(thisfile,'r');
fo = fopen(tempfile,'wt');
if fo<0
error('GitHub:GitHub:tempnameFailed',...
'Could not write temporary file to %s.',tempfile);
end
while ~feof(fi)
buffer = fgetl(fi);
buffer
if strcmp(buffer,'%##%')
keyboard
thishost = strtrim(evalc('system(''hostname'');'));
fprintf(fo,' case ''%s''\n',thishost);
fprintf(fo,' p = fullfile(''%s'',varargin{:});\n',dbdr);
fprintf('Host ''%s'' added to %s.m!\n',thishost,mfilename);
end
fprintf(fo,'%s\n',buffer);
end
fclose(fi);
fclose(fo);
[success errmsg errid] = movefile(tempfile,thisfile,'f');
if ~success
error(errid,errmsg);
end
end