forked from amazingfate/loongoffice
Change-Id: I6a92196f33d7a5278c7dcc426112e9c56d582655 Reviewed-on: https://gerrit.libreoffice.org/4627 Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
67 lines
2.4 KiB
C++
67 lines
2.4 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
*/
|
|
#ifndef _TOOLS_TEMPFILE_HXX
|
|
#define _TOOLS_TEMPFILE_HXX
|
|
|
|
#include <rtl/ustring.hxx>
|
|
#include "tools/toolsdllapi.h"
|
|
|
|
struct TempFile_Impl;
|
|
class TOOLS_DLLPUBLIC TempFile
|
|
{
|
|
TempFile_Impl* pImp;
|
|
bool bKillingFileEnabled;
|
|
|
|
public:
|
|
/** Create a temporary file in the default tempfile folder. */
|
|
TempFile();
|
|
|
|
/** Create a temporary file in the default tempfile folder; its name starts
|
|
with some given characters followed by a counter ( example:
|
|
rLeadingChars="abc" means "abc0", "abc1" and so on, depending on
|
|
existing files in that folder ).
|
|
|
|
The extension string may be f.e. ".txt" or "", if no extension string is
|
|
given, ".tmp" is used.
|
|
*/
|
|
TempFile( const OUString& rLeadingChars, const OUString* pExtension=NULL );
|
|
|
|
/** TempFile will be removed from disk in dtor if EnableKillingTempFile was
|
|
called before. TempDirs will be removed recursively in that case. */
|
|
~TempFile();
|
|
|
|
bool IsValid() const;
|
|
|
|
/** Returns the real name of the tempfile in file URL scheme. */
|
|
OUString GetName() const;
|
|
|
|
/** If enabled the file will be removed from disk when the dtor is called
|
|
(default is not enabled) */
|
|
void EnableKillingFile( bool bEnable=true ) { bKillingFileEnabled = bEnable; }
|
|
|
|
bool IsKillingFileEnabled() const { return bKillingFileEnabled; }
|
|
|
|
/** Only create a name for a temporary file that would be valid at that moment. */
|
|
static OUString CreateTempName();
|
|
};
|
|
|
|
#endif
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|