linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH] obex: Use GLib helper function to manipulate paths
Date: Sat, 09 Nov 2013 18:18:07 +0100	[thread overview]
Message-ID: <1384017487.3880.42.camel@nuvo> (raw)


Instead of trying to do it by hand. This also makes sure that
relative paths aren't used by the agent.
---
 obexd/src/manager.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index cec8a39..f18896e 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -651,14 +651,14 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
 				DBUS_TYPE_STRING, &name,
 				DBUS_TYPE_INVALID)) {
 		/* Splits folder and name */
-		const char *slash = strrchr(name, '/');
+		gboolean is_relative = !g_path_is_absolute(name);
 		DBG("Agent replied with %s", name);
-		if (!slash) {
-			agent->new_name = g_strdup(name);
+		if (is_relative) {
+			agent->new_name = g_path_get_basename(name);
 			agent->new_folder = NULL;
 		} else {
-			agent->new_name = g_strdup(slash + 1);
-			agent->new_folder = g_strndup(name, slash - name);
+			agent->new_name = g_path_get_basename(name);
+			agent->new_folder = g_path_get_dirname(name);
 		}
 	}
 
-- 
1.8.4.2



             reply	other threads:[~2013-11-09 17:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-09 17:18 Bastien Nocera [this message]
2017-11-24 14:12 ` [PATCH] obex: Use GLib helper function to manipulate paths Bastien Nocera
2017-11-24 15:12   ` Luiz Augusto von Dentz
2017-11-24 15:18     ` Bastien Nocera

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384017487.3880.42.camel@nuvo \
    --to=hadess@hadess.net \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).