Skip to content

Commit

Permalink
Remove the old interpret_tilde functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoureaux committed Jan 3, 2024
1 parent 967b8b5 commit 365d1eb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 47 deletions.
44 changes: 0 additions & 44 deletions utility/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,50 +1122,6 @@ void free_multicast_group()
mc_group = nullptr;
}

/**
Interpret ~/ in filename as home dir
New path is returned in buf of size buf_size
This may fail if the path is too long. It is better to use
interpret_tilde_alloc.
*/
void interpret_tilde(char *buf, size_t buf_size, const QString &filename)
{
if (filename.startsWith(QLatin1String("~/"))) {
fc_snprintf(buf, buf_size, "%s/%s", qUtf8Printable(QDir::homePath()),
qUtf8Printable(filename.right(filename.length() - 2)));
} else if (filename == QLatin1String("~")) {
qstrncpy(buf, qUtf8Printable(QDir::homePath()), buf_size);
} else {
qstrncpy(buf, qUtf8Printable(filename), buf_size);
}
}

/**
Interpret ~/ in filename as home dir
The new path is returned in buf, as a newly allocated buffer. The new
path will always be allocated and written, even if there is no ~ present.
*/
char *interpret_tilde_alloc(const char *filename)
{
if (filename[0] == '~' && filename[1] == '/') {
QString home = QDir::homePath();
size_t sz;
char *buf;

filename += 2; /* Skip past "~/" */
sz = home.length() + qstrlen(filename) + 2;
buf = static_cast<char *>(fc_malloc(sz));
fc_snprintf(buf, sz, "%s/%s", qUtf8Printable(home), filename);
return buf;
} else if (filename[0] == '~' && filename[1] == '\0') {
return fc_strdup(qUtf8Printable(QDir::homePath()));
} else {
return fc_strdup(filename);
}
}

/**
* Interpret ~ in filename as home dir
*/
Expand Down
3 changes: 0 additions & 3 deletions utility/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ enum m_pre_result match_prefix_full(m_pre_accessor_fn_t accessor_fn,
char *get_multicast_group(bool ipv6_preferred);
void free_multicast_group();

[[deprecated]] void interpret_tilde(char *buf, size_t buf_size,
const QString &filename);
[[deprecated]] char *interpret_tilde_alloc(const char *filename);
QString interpret_tilde(const QString &filename);

bool make_dir(const QString &pathname);
Expand Down

0 comments on commit 365d1eb

Please sign in to comment.