From ef89d96701172ff8dee0b6a0244a8c088f61734c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Wed, 9 Jan 2008 11:12:16 +0000 Subject: [PATCH] Work around BeOS ftpd (sets 640) + robinhood (doesn't like 640) by adding Chmod() support. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23298 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/codycam/FtpClient.cpp | 27 +++++++++++++++++++++++++++ src/apps/codycam/FtpClient.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/apps/codycam/FtpClient.cpp b/src/apps/codycam/FtpClient.cpp index 0441eb2fca..bcb9b28f88 100644 --- a/src/apps/codycam/FtpClient.cpp +++ b/src/apps/codycam/FtpClient.cpp @@ -245,6 +245,8 @@ FtpClient::PutFile(const string& local, const string& remote, ftp_mode mode) if (rc) { _GetReply(replyString, code, codeType); rc = codeType <= 2; + // at least BeOS' ftpd forces 640 which RobinHood doesn't like... + Chmod(remote, "644"); } return rc; @@ -357,6 +359,31 @@ FtpClient::MoveFile(const string& oldPath, const string& newPath) } +bool +FtpClient::Chmod(const string& path, const string& mod) +{ + bool rc = false; + int code, codeType; + string cmd = "SITE CHMOD ", replyString; + + cmd += mod; + cmd += " "; + cmd += path; + + if (path.length() == 0) + cmd += '/'; +printf("cmd: '%s'\n", cmd.c_str()); + if (_SendRequest(cmd) == true) { + if (_GetReply(replyString, code, codeType) == true) { +printf("reply: %d, %d\n", code, codeType); + if (codeType == 2) + rc = true; + } + } + return rc; +} + + void FtpClient::SetPassive(bool on) { diff --git a/src/apps/codycam/FtpClient.h b/src/apps/codycam/FtpClient.h index 91faeb730e..ac91f6dd91 100644 --- a/src/apps/codycam/FtpClient.h +++ b/src/apps/codycam/FtpClient.h @@ -45,6 +45,7 @@ class FtpClient { bool ChangeDir(const string& dir); bool PrintWorkingDir(string& dir); bool ListDirContents(string& listing); + bool Chmod(const string& path, const string& mod); void SetPassive(bool on);