29.04.2014 - Version 0.4.0_prealpha. PICodeParser, namespace PICodeInfo, new tool "pip_cmg" in dir "code_model_generator". New feature in PIIODevice - "createFromFullPath", all parameters of all I/O devices now works with PIObjects`s properties.
This commit is contained in:
16
pifile.h
16
pifile.h
@@ -4,7 +4,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
File
|
||||
Copyright (C) 2013 Ivan Pelipenko peri4ko@gmail.com
|
||||
Copyright (C) 2014 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -28,11 +28,11 @@
|
||||
|
||||
class PIP_EXPORT PIFile: public PIIODevice
|
||||
{
|
||||
PIOBJECT(PIFile)
|
||||
PIIODEVICE(PIFile)
|
||||
public:
|
||||
|
||||
//! Constructs a file with path "path" nad open mode "type"
|
||||
PIFile(const PIString & path = PIString(), DeviceMode type = ReadWrite): PIIODevice(path, type) {setPrecision(5); openDevice();}
|
||||
PIFile(const PIString & path = PIString(), DeviceMode mode = ReadWrite): PIIODevice(path, mode) {setPrecision(5); if (!path.isEmpty()) openDevice();}
|
||||
|
||||
~PIFile() {close();}
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
|
||||
|
||||
//! Set file path to "path" and reopen file if need
|
||||
void setPath(const PIString & path) {path_ = path; if (opened_) openDevice();}
|
||||
void setPath(const PIString & path) {PIIODevice::setPath(path); if (opened_) openDevice();}
|
||||
|
||||
//! Returns file size
|
||||
llong size();
|
||||
@@ -125,7 +125,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) {path_ = 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;}
|
||||
@@ -184,8 +184,8 @@ public:
|
||||
PIFile & operator >>(double & v) {if (canRead() && fd != 0) ret = fscanf(fd, "%lf", &v); return *this;}
|
||||
|
||||
|
||||
EVENT_HANDLER(void, clear) {close(); fd = fopen(path_.data(), "w"); if (fd != 0) fclose(fd); fd = 0; opened_ = false; open();}
|
||||
EVENT_HANDLER0(void, remove) {close(); std::remove(path_.data());}
|
||||
EVENT_HANDLER(void, clear) {close(); fd = fopen(path().data(), "w"); if (fd != 0) fclose(fd); fd = 0; opened_ = false; open();}
|
||||
EVENT_HANDLER0(void, remove) {close(); std::remove(path().data());}
|
||||
EVENT_HANDLER1(void, resize, llong, new_size) {resize(new_size, 0);}
|
||||
EVENT_HANDLER2(void, resize, llong, new_size, uchar, fill);
|
||||
|
||||
@@ -222,6 +222,8 @@ public:
|
||||
//! \}
|
||||
|
||||
protected:
|
||||
PIString fullPathPrefix() const {return "file";}
|
||||
void configureFromFullPath(const PIString & full_path);
|
||||
bool openDevice();
|
||||
bool closeDevice();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user