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() |
248 | 248 | { |
249 | 249 | if (isLocal()) |
250 | 250 | { |
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 | | } |
257 | 251 | if (writemode) |
258 | 252 | { |
| 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 | |
259 | 263 | fileWriter = new ThreadedFileWriter(path, |
260 | 264 | O_WRONLY|O_TRUNC|O_CREAT|O_LARGEFILE, |
261 | 265 | 0644); |
… |
… |
bool RemoteFile::OpenInternal() |
272 | 276 | return true; |
273 | 277 | } |
274 | 278 | // 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 | } |
275 | 285 | localFile = ::open(path.toLocal8Bit().constData(), O_RDONLY); |
276 | 286 | if (localFile == -1) |
277 | 287 | { |