File indexing completed on 2024-05-12 17:16:20

0001 /*
0002  * Port for usage with qt-framework and development for kdesvn
0003  * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de)
0004  * http://kdesvn.alwins-world.de
0005  */
0006 /*
0007  * ====================================================================
0008  * Copyright (c) 2002-2005 The RapidSvn Group.  All rights reserved.
0009  * dev@rapidsvn.tigris.org
0010  *
0011  * This library is free software; you can redistribute it and/or
0012  * modify it under the terms of the GNU Lesser General Public
0013  * License as published by the Free Software Foundation; either
0014  * version 2.1 of the License, or (at your option) any later version.
0015  *
0016  * This library is distributed in the hope that it will be useful,
0017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0019  * Lesser General Public License for more details.
0020  *
0021  * You should have received a copy of the GNU Lesser General Public
0022  * License along with this library (in the file LGPL.txt); if not,
0023  * write to the Free Software Foundation, Inc., 51 Franklin St,
0024  * Fifth Floor, Boston, MA  02110-1301  USA
0025  *
0026  * This software consists of voluntary contributions made by many
0027  * individuals.  For exact contribution history, see the revision
0028  * history and logs, available at http://rapidsvn.tigris.org/.
0029  * ====================================================================
0030  */
0031 
0032 // svncpp
0033 #include "client_impl.h"
0034 
0035 // Subversion api
0036 #include <svn_client.h>
0037 
0038 #include "exception.h"
0039 #include "pool.h"
0040 #include "status.h"
0041 #include "svnqt_defines.h"
0042 #include "svnstream.h"
0043 #include "svnfilestream.h"
0044 
0045 namespace svn
0046 {
0047 QByteArray
0048 Client_impl::cat(const Path &path,
0049                  const Revision &revision,
0050                  const Revision &peg_revision)
0051 {
0052     svn::stream::SvnByteStream buffer(*m_context);
0053     svn_error_t *error = internal_cat(path, revision, peg_revision, buffer);
0054     if (error != nullptr) {
0055         throw ClientException(error);
0056     }
0057 
0058     return buffer.content();
0059 }
0060 
0061 void
0062 Client_impl::cat(svn::stream::SvnStream &buffer,
0063                  const Path &path,
0064                  const Revision &revision,
0065                  const Revision &peg_revision)
0066 {
0067     svn_error_t *error = internal_cat(path, revision, peg_revision, buffer);
0068     if (error != nullptr) {
0069         throw ClientException(error);
0070     }
0071 }
0072 
0073 void
0074 Client_impl::get(const Path &path,
0075                  const QString   &target,
0076                  const Revision &revision,
0077                  const Revision &peg_revision)
0078 {
0079     svn::stream::SvnFileOStream buffer(target, *m_context);
0080     svn_error_t *error = internal_cat(path, revision, peg_revision, buffer);
0081     if (error != nullptr) {
0082         throw ClientException(error);
0083     }
0084 }
0085 
0086 svn_error_t *Client_impl::internal_cat(const Path &path,
0087                                        const Revision &revision,
0088                                        const Revision &peg_revision,
0089                                        svn::stream::SvnStream &buffer)
0090 {
0091     Pool pool;
0092     return svn_client_cat2(buffer,
0093                            path.path().toUtf8(),
0094                            peg_revision.revision(),
0095                            revision.revision(),
0096                            *m_context,
0097                            pool);
0098 }
0099 
0100 }
0101 
0102 /* -----------------------------------------------------------------
0103  * local variables:
0104  * eval: (load-file "../../rapidsvn-dev.el")
0105  * end:
0106  */