Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
4bd66879
Commit
4bd66879
authored
16 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Use "correct" paths under OS X
parent
c3d8d1e3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/syncterm/syncterm.c
+95
-5
95 additions, 5 deletions
src/syncterm/syncterm.c
with
95 additions
and
5 deletions
src/syncterm/syncterm.c
+
95
−
5
View file @
4bd66879
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
/* $Id$ */
/* $Id$ */
#if defined(__APPLE__) && defined(__MACH__)
#include
<CoreServices/CoreServices.h>
// FSFindFolder() and friends
#endif
#define NOCRYPT
/* Stop windows.h from loading wincrypt.h */
#define NOCRYPT
/* Stop windows.h from loading wincrypt.h */
/* Is windows.h REALLY necessary?!?! */
/* Is windows.h REALLY necessary?!?! */
#define WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
...
@@ -813,6 +817,64 @@ void parse_url(char *url, struct bbslist *bbs, int dflt_conn_type, int force_def
...
@@ -813,6 +817,64 @@ void parse_url(char *url, struct bbslist *bbs, int dflt_conn_type, int force_def
free_list
(
&
list
[
0
],
listcount
);
free_list
(
&
list
[
0
],
listcount
);
}
}
#if defined(__APPLE__) && defined(__MACH__)
static
char
*
get_new_OSX_filename
(
char
*
fn
,
int
fnlen
,
int
type
,
int
shared
)
{
FSRef
ref
;
long
size
;
/* First, get the path */
switch
(
type
)
{
case
SYNCTERM_PATH_INI
:
case
SYNCTERM_PATH_LIST
:
if
(
FSFindFolder
(
shared
?
kLocalDomain
:
kUserDomain
,
kPreferencesFolderType
,
kCreateFolder
,
&
ref
)
!=
noErr
)
return
(
NULL
);
if
(
FSRefMakePath
(
&
ref
,
(
unsigned
char
*
)
fn
,
fnlen
)
!=
noErr
)
return
(
NULL
);
backslash
(
fn
);
strncat
(
fn
,
"SyncTERM"
,
fnlen
);
backslash
(
fn
);
if
(
!
isdir
(
fn
))
{
if
(
MKDIR
(
fn
))
return
(
NULL
);
}
break
;
case
SYNCTERM_DEFAULT_TRANSFER_PATH
:
/* I'd love to use the "right" setting here, but don't know how */
if
(
FSFindFolder
(
shared
?
kLocalDomain
:
kUserDomain
,
kDesktopFolderType
,
kCreateFolder
,
&
ref
)
!=
noErr
)
return
(
NULL
);
if
(
FSRefMakePath
(
&
ref
,
(
unsigned
char
*
)
fn
,
fnlen
)
!=
noErr
)
return
(
NULL
);
backslash
(
fn
);
strncat
(
fn
,
"SyncTERM"
,
fnlen
);
backslash
(
fn
);
if
(
!
isdir
(
fn
))
{
if
(
MKDIR
(
fn
))
return
(
NULL
);
}
return
(
fn
);
case
SYNCTERM_PATH_CACHE
:
if
(
FSFindFolder
(
shared
?
kLocalDomain
:
kUserDomain
,
kCachedDataFolderType
,
kCreateFolder
,
&
ref
)
!=
noErr
)
return
(
NULL
);
if
(
FSRefMakePath
(
&
ref
,
(
unsigned
char
*
)
fn
,
fnlen
)
!=
noErr
)
return
(
NULL
);
backslash
(
fn
);
return
(
fn
);
}
switch
(
type
)
{
case
SYNCTERM_PATH_INI
:
strncat
(
fn
,
"SyncTERM.ini"
,
fnlen
);
return
(
fn
);
case
SYNCTERM_PATH_LIST
:
strncat
(
fn
,
"SyncTERM.lst"
,
fnlen
);
return
(
fn
);
}
return
(
NULL
);
}
#endif
char
*
get_syncterm_filename
(
char
*
fn
,
int
fnlen
,
int
type
,
int
shared
)
char
*
get_syncterm_filename
(
char
*
fn
,
int
fnlen
,
int
type
,
int
shared
)
{
{
char
oldlst
[
MAX_PATH
+
1
];
char
oldlst
[
MAX_PATH
+
1
];
...
@@ -887,11 +949,12 @@ char *get_syncterm_filename(char *fn, int fnlen, int type, int shared)
...
@@ -887,11 +949,12 @@ char *get_syncterm_filename(char *fn, int fnlen, int type, int shared)
break
;
break
;
}
}
#else
#else
/* UNIX */
char
*
home
=
NULL
;
char
*
home
=
NULL
;
if
(
inpath
==
NULL
)
if
(
inpath
==
NULL
)
home
=
getenv
(
"HOME"
);
home
=
getenv
(
"HOME"
);
if
(
home
==
NULL
||
strlen
(
home
)
>
MAX_PATH
-
32
)
{
/* $HOME just too damn big */
if
(
!
shared
&&
(
home
==
NULL
||
strlen
(
home
)
>
MAX_PATH
-
32
)
)
{
/* $HOME just too damn big */
if
(
type
==
SYNCTERM_DEFAULT_TRANSFER_PATH
||
type
==
SYNCTERM_PATH_CACHE
)
{
if
(
type
==
SYNCTERM_DEFAULT_TRANSFER_PATH
||
type
==
SYNCTERM_PATH_CACHE
)
{
getcwd
(
fn
,
fnlen
);
getcwd
(
fn
,
fnlen
);
backslash
(
fn
);
backslash
(
fn
);
...
@@ -908,6 +971,10 @@ char *get_syncterm_filename(char *fn, int fnlen, int type, int shared)
...
@@ -908,6 +971,10 @@ char *get_syncterm_filename(char *fn, int fnlen, int type, int shared)
if
(
type
==
SYNCTERM_DEFAULT_TRANSFER_PATH
)
{
if
(
type
==
SYNCTERM_DEFAULT_TRANSFER_PATH
)
{
strcpy
(
fn
,
home
);
strcpy
(
fn
,
home
);
backslash
(
fn
);
backslash
(
fn
);
#if defined(__APPLE__) && defined(__MACH__)
if
(
get_new_OSX_filename
(
oldlst
,
sizeof
(
oldlst
),
type
,
shared
)
!=
NULL
)
strcpy
(
fn
,
oldlst
);
#endif
if
(
!
isdir
(
fn
))
if
(
!
isdir
(
fn
))
MKDIR
(
fn
);
MKDIR
(
fn
);
return
(
fn
);
return
(
fn
);
...
@@ -929,11 +996,13 @@ char *get_syncterm_filename(char *fn, int fnlen, int type, int shared)
...
@@ -929,11 +996,13 @@ char *get_syncterm_filename(char *fn, int fnlen, int type, int shared)
#endif
#endif
}
}
#if !(defined(__APPLE__) && defined(__MACH__))
/* Create if it doesn't exist */
/* Create if it doesn't exist */
if
(
!
isdir
(
fn
)
&&
!
shared
)
{
if
(
!
isdir
(
fn
)
&&
!
shared
)
{
if
(
MKDIR
(
fn
))
if
(
MKDIR
(
fn
))
fn
[
0
]
=
0
;
fn
[
0
]
=
0
;
}
}
#endif
switch
(
type
)
{
switch
(
type
)
{
case
SYNCTERM_PATH_INI
:
case
SYNCTERM_PATH_INI
:
...
@@ -945,17 +1014,38 @@ char *get_syncterm_filename(char *fn, int fnlen, int type, int shared)
...
@@ -945,17 +1014,38 @@ char *get_syncterm_filename(char *fn, int fnlen, int type, int shared)
case
SYNCTERM_PATH_CACHE
:
case
SYNCTERM_PATH_CACHE
:
strncat
(
fn
,
"cache"
,
fnlen
);
strncat
(
fn
,
"cache"
,
fnlen
);
backslash
(
fn
);
backslash
(
fn
);
#if !(defined(__APPLE__) && defined(__MACH__))
if
(
!
isdir
(
fn
))
{
if
(
!
isdir
(
fn
))
{
if
(
MKDIR
(
fn
))
if
(
MKDIR
(
fn
))
fn
[
0
]
=
0
;
fn
[
0
]
=
0
;
}
}
#endif
break
;
break
;
}
}
#endif
/* Copy pre-0.7 version of the syncterm.lst file to new location */
#if defined(__APPLE__) && defined(__MACH__)
if
(
!
shared
&&
type
==
SYNCTERM_PATH_LIST
&&
(
!
fexist
(
fn
))
&&
fexist
(
oldlst
))
rename
(
oldlst
,
fn
);
strcpy
(
oldlst
,
fn
);
if
(
get_new_OSX_filename
(
fn
,
fnlen
,
type
,
shared
)
!=
NULL
)
{
if
(
fexist
(
oldlst
))
{
if
(
!
isdir
(
oldlst
))
{
char
*
lastslash
=
strrchr
(
oldlst
,
'/'
);
rename
(
oldlst
,
fn
);
if
(
lastslash
)
{
*
(
lastslash
+
1
)
=
'*'
;
*
(
lastslash
+
2
)
=
0
;
if
(
!
fexist
(
oldlst
))
{
*
lastslash
=
0
;
rmdir
(
oldlst
);
}
}
}
}
}
#endif
/* OS X */
#endif
/* !Win32 */
return
(
fn
);
return
(
fn
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment