Ticket #12424: 0007-RemoteFile-Fix-writing-of-local-files.patch

File 0007-RemoteFile-Fix-writing-of-local-files.patch, 1.9 KB (added by Roger Siddons <dizygotheca@…>, 5 years ago)
  • mythtv/libs/libmythbase/remotefile.cpp

    From 8f307ae53dc2115c76a99eaa5c42075c239b755c Mon Sep 17 00:00:00 2001
    From: Roger Siddons <dizygotheca@ntlworld.com>
    Date: Sat, 22 Aug 2015 13:14:20 +0100
    Subject: [PATCH 07/15] RemoteFile: Fix writing of local files
    
    Attempting to write a local file fails unless the file already exists.
    
    This patch permits creation of new files, as well as overwriting existing ones.
    
    diff --git a/mythtv/libs/libmythbase/remotefile.cpp b/mythtv/libs/libmythbase/remotefile.cpp
    index b1c4fed..469c292 100644
    a b bool RemoteFile::OpenInternal() 
    248248{
    249249    if (isLocal())
    250250    {
    251         if (!Exists(path))
    252         {
    253             LOG(VB_FILE, LOG_ERR,
    254                 QString("RemoteFile::Open(%1) Error: Do not exist").arg(path));
    255             return false;
    256         }
    257251        if (writemode)
    258252        {
     253            QString dirPath = QFileInfo(path).absolutePath();
     254            QDir qdir;
     255            if (!qdir.mkpath(dirPath))
     256            {
     257                LOG(VB_FILE, LOG_ERR,
     258                    QString("RemoteFile::Open(%1) Error: File is in a subdirectory "
     259                            "which does not exist, and can not be created.").arg(path));
     260                return false;
     261            }
     262
    259263            fileWriter = new ThreadedFileWriter(path,
    260264                                                O_WRONLY|O_TRUNC|O_CREAT|O_LARGEFILE,
    261265                                                0644);
    bool RemoteFile::OpenInternal() 
    272276            return true;
    273277        }
    274278        // local mode, read only
     279        if (!Exists(path))
     280        {
     281            LOG(VB_FILE, LOG_ERR,
     282                QString("RemoteFile::Open(%1) Error: Do not exist").arg(path));
     283            return false;
     284        }
    275285        localFile = ::open(path.toLocal8Bit().constData(), O_RDONLY);
    276286        if (localFile == -1)
    277287        {