diff --git a/src/io/pibinarylog.h b/src/io/pibinarylog.h index 6ed9109f..63d319ce 100644 --- a/src/io/pibinarylog.h +++ b/src/io/pibinarylog.h @@ -37,7 +37,7 @@ class PIBinaryLog: public PIIODevice { PIIODEVICE(PIBinaryLog) public: - PIBinaryLog(); + explicit PIBinaryLog(); ~PIBinaryLog() {closeDevice();} //! \brief Play modes for \a PIBinaryLog diff --git a/src/io/pifile.cpp b/src/io/pifile.cpp index 682f98f3..8c96b857 100755 --- a/src/io/pifile.cpp +++ b/src/io/pifile.cpp @@ -137,13 +137,13 @@ PIFile::PIFile(const PIString & path, PIIODevice::DeviceMode mode): PIIODevice(p } -PIFile::PIFile(const PIFile & other) { - fd = 0; - fdi = -1; - setPrecision(other.prec_); - setPath(other.path()); - mode_ = other.mode_; -} +//PIFile::PIFile(const PIFile & other) { +// fd = 0; +// fdi = -1; +// setPrecision(other.prec_); +// setPath(other.path()); +// mode_ = other.mode_; +//} bool PIFile::openDevice() { diff --git a/src/io/pifile.h b/src/io/pifile.h index b1fbd120..bff83209 100755 --- a/src/io/pifile.h +++ b/src/io/pifile.h @@ -86,7 +86,11 @@ public: //! Constructs a file with path "path" and open mode "mode" explicit PIFile(const PIString & path, DeviceMode mode = ReadWrite); - PIFile(const PIFile & other); + + //! Open temporary file with open mode "mode" + bool openTemporary(PIIODevice::DeviceMode mode = PIIODevice::ReadWrite) {return open(PIString(tmpnam(0)), mode);} + +// PIFile(const PIFile & other); ~PIFile() {closeDevice();} @@ -176,7 +180,7 @@ public: //! Write to file binary content of "v" PIFile & writeBinary(const double v) {write(&v, sizeof(v)); return *this;} - PIFile & operator =(const PIFile & f) {PIIODevice::setPath(f.path()); mode_ = f.mode_; return *this;} + //PIFile & operator =(const PIFile & f) {PIIODevice::setPath(f.path()); mode_ = f.mode_; return *this;} //! Write to file text representation of "v" PIFile & operator <<(const char v) {if (canWrite() && fd != 0) write(&v, 1); return *this;} @@ -244,9 +248,6 @@ public: //! static void setDefaultCharset(const char * c); - - //! Returns opened temporary file with open mode "mode" - static PIFile openTemporary(PIIODevice::DeviceMode mode = PIIODevice::ReadWrite) {return PIFile(PIString(tmpnam(0)), mode);} //! Returns if file with path "path" does exists static bool isExists(const PIString & path); diff --git a/src/io/piiobytearray.h b/src/io/piiobytearray.h index 975b92ba..97fdb398 100644 --- a/src/io/piiobytearray.h +++ b/src/io/piiobytearray.h @@ -32,10 +32,10 @@ class PIP_EXPORT PIIOByteArray: public PIIODevice public: //! Contructs %PIIOByteArray with \"buffer\" content and \"mode\" open mode - PIIOByteArray(PIByteArray * buffer = 0, PIIODevice::DeviceMode mode = PIIODevice::ReadWrite); + explicit PIIOByteArray(PIByteArray * buffer = 0, PIIODevice::DeviceMode mode = PIIODevice::ReadWrite); //! Contructs %PIIOByteArray with \"buffer\" content only for read - PIIOByteArray(const PIByteArray & buffer); + explicit PIIOByteArray(const PIByteArray & buffer); ~PIIOByteArray() {closeDevice();} diff --git a/src/io/piiodevice.h b/src/io/piiodevice.h index 6fd381eb..a033b826 100755 --- a/src/io/piiodevice.h +++ b/src/io/piiodevice.h @@ -53,7 +53,7 @@ class PIP_EXPORT PIIODevice: public PIThread public: //! Constructs a empty PIIODevice - PIIODevice(); + explicit PIIODevice(); //! \brief Open modes for PIIODevice enum DeviceMode { @@ -70,7 +70,7 @@ public: typedef PIFlags DeviceOptions; - PIIODevice(const PIString & path, DeviceMode mode = ReadWrite); + explicit PIIODevice(const PIString & path, DeviceMode mode = ReadWrite); virtual ~PIIODevice(); //! Current open mode of device @@ -356,6 +356,8 @@ private: void run(); void end() {terminate();} static void cacheFullPath(const PIString & full_path, const PIIODevice * d); + explicit PIIODevice(const PIIODevice & ); + void operator =(const PIIODevice & ); PITimer timer; PITimeMeasurer tm; diff --git a/src/io/piiostring.h b/src/io/piiostring.h index 78d3886d..55b2e060 100644 --- a/src/io/piiostring.h +++ b/src/io/piiostring.h @@ -32,10 +32,10 @@ class PIP_EXPORT PIIOString: public PIIODevice public: //! Contructs %PIIOString with \"string\" content and \"mode\" open mode - PIIOString(PIString * string = 0, PIIODevice::DeviceMode mode = PIIODevice::ReadWrite); + explicit PIIOString(PIString * string = 0, PIIODevice::DeviceMode mode = PIIODevice::ReadWrite); //! Contructs %PIIOString with \"string\" content only for read - PIIOString(const PIString & string); + explicit PIIOString(const PIString & string); ~PIIOString() {closeDevice();} diff --git a/src/io/pipacketextractor.h b/src/io/pipacketextractor.h index 07ec78b9..53ddb136 100755 --- a/src/io/pipacketextractor.h +++ b/src/io/pipacketextractor.h @@ -46,7 +46,7 @@ public: }; //! Contructs extractor with child device "device_" and extract algorithm "mode" - PIPacketExtractor(PIIODevice * device_ = 0, SplitMode mode = None); + explicit PIPacketExtractor(PIIODevice * device_ = 0, SplitMode mode = None); virtual ~PIPacketExtractor() {stop();} diff --git a/src/io/pitransparentdevice.h b/src/io/pitransparentdevice.h index f8e68b91..c6020eac 100644 --- a/src/io/pitransparentdevice.h +++ b/src/io/pitransparentdevice.h @@ -32,7 +32,7 @@ class PIP_EXPORT PITransparentDevice: public PIIODevice public: //! Contructs empty %PITransparentDevice - PITransparentDevice(); + explicit PITransparentDevice(); ~PITransparentDevice() {closeDevice();} diff --git a/src/io/piusb.h b/src/io/piusb.h index 8b1169d5..d31b3cdd 100755 --- a/src/io/piusb.h +++ b/src/io/piusb.h @@ -31,7 +31,7 @@ class PIP_EXPORT PIUSB: public PIIODevice { PIIODEVICE(PIUSB) public: - PIUSB(ushort vid = 0, ushort pid = 0); + explicit PIUSB(ushort vid = 0, ushort pid = 0); ~PIUSB() {closeDevice();} struct Endpoint { diff --git a/src/piversion.h b/src/piversion.h index 29a49d52..22ef44fb 100644 --- a/src/piversion.h +++ b/src/piversion.h @@ -3,7 +3,7 @@ #define PIVERSION_H #define PIP_VERSION_MAJOR 0 -#define PIP_VERSION_MINOR 8 +#define PIP_VERSION_MINOR 9 #define PIP_VERSION_REVISION 0 #define PIP_VERSION_SUFFIX "" diff --git a/src/system/picodec.cpp b/src/system/picodec.cpp index e64a150e..0c7f9ef1 100755 --- a/src/system/picodec.cpp +++ b/src/system/picodec.cpp @@ -31,7 +31,7 @@ PIStringList PICodec::availableCodecs() { PIByteArray PICodec::exec_iconv(const PIString & from, const PIString & to, const PIByteArray & str) { - tf.open(); + tf.openTemporary(PIIODevice::ReadWrite); tf.clear(); tf << str; tf.close(); diff --git a/src/system/picodec.h b/src/system/picodec.h index 74faad67..3fde3381 100755 --- a/src/system/picodec.h +++ b/src/system/picodec.h @@ -26,8 +26,8 @@ class PIP_EXPORT PICodec: private PIProcess { PIOBJECT(PICodec) public: - PICodec(): PIProcess() {setGrabOutput(true); tf = PIFile::openTemporary(PIIODevice::ReadWrite); tf.open();} - PICodec(const PIString & from, const PIString & to): PIProcess() {setCodings(from, to); tf = PIFile::openTemporary(PIIODevice::ReadWrite);} + PICodec(): PIProcess() {setGrabOutput(true);} + PICodec(const PIString & from, const PIString & to): PIProcess() {setCodings(from, to);} ~PICodec() {tf.remove();} void setFromCoding(const PIString & from) {c_from = from;} diff --git a/src/system/piprocess.cpp b/src/system/piprocess.cpp index 6dd3f265..ca3a1752 100755 --- a/src/system/piprocess.cpp +++ b/src/system/piprocess.cpp @@ -106,17 +106,17 @@ void PIProcess::startProc(bool detached) { /// files for stdin/out/err t_in = t_out = t_err = false; if (f_in.path().isEmpty()) { - f_in = PIFile::openTemporary(PIIODevice::ReadWrite); + f_in.openTemporary(PIIODevice::ReadWrite); t_in = true; } //f_in.open(PIIODevice::ReadWrite); f_in.close(); if (f_out.path().isEmpty()) { - f_out = PIFile::openTemporary(PIIODevice::ReadWrite); + f_out.openTemporary(PIIODevice::ReadWrite); t_out = true; } //f_out.open(PIIODevice::WriteOnly); f_out.close(); if (f_err.path().isEmpty()) { - f_err = PIFile::openTemporary(PIIODevice::ReadWrite); + f_err.openTemporary(PIIODevice::ReadWrite); t_err = true; } //f_err.open(PIIODevice::WriteOnly); f_err.close();