git-svn-id: svn://db.shs.com.ru/pip@284 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -140,12 +140,27 @@ PIIODevice::~PIIODevice() {
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::setOptions(PIIODevice::DeviceOptions o) {
|
||||
options_ = o;
|
||||
optionsChanged();
|
||||
}
|
||||
|
||||
|
||||
bool PIIODevice::setOption(PIIODevice::DeviceOption o, bool yes) {
|
||||
bool ret = isOptionSet(o);
|
||||
options_.setFlag(o, yes);
|
||||
optionsChanged();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::_init() {
|
||||
opened_ = init_ = thread_started_ = false;
|
||||
raise_threaded_read_ = true;
|
||||
ret_func_ = 0;
|
||||
ret_data_ = 0;
|
||||
tri = 0;
|
||||
setOptions(0);
|
||||
setReopenEnabled(true);
|
||||
setReopenTimeout(1000);
|
||||
setThreadedReadBufferSize(4096);
|
||||
@@ -284,6 +299,62 @@ bool PIIODevice::configure(const PIString & config_file, const PIString & sectio
|
||||
}
|
||||
|
||||
|
||||
PIString PIIODevice::constructFullPath() const {
|
||||
return fullPathPrefix() + "://" + constructFullPathDevice() + fullPathOptions();
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::configureFromFullPath(const PIString & full_path) {
|
||||
PIString fp;
|
||||
DeviceMode dm = ReadWrite;
|
||||
DeviceOptions op = 0;
|
||||
splitFullPath(full_path, &fp, &dm, &op);
|
||||
setMode(dm);
|
||||
setOptions(op);
|
||||
configureFromFullPathDevice(fp);
|
||||
}
|
||||
|
||||
|
||||
void PIIODevice::splitFullPath(PIString fpwm, PIString * full_path, DeviceMode * mode, DeviceOptions * opts) {
|
||||
int dm = 0;
|
||||
DeviceOptions op = 0;
|
||||
if (fpwm.find("(") > 0 && fpwm.find(")") > 0) {
|
||||
PIString dms(fpwm.right(fpwm.length() - fpwm.findLast("(")).takeRange("(", ")").trim().toLowerCase().removeAll(" "));
|
||||
PIStringList opts(dms.split(","));
|
||||
piForeachC (PIString & o, opts) {
|
||||
//piCout << dms;
|
||||
if (o == "r" || o == "ro" || o == "read" || o == "readonly")
|
||||
dm |= ReadOnly;
|
||||
if (o == "w" || o == "wo" || o == "write" || o == "writeonly")
|
||||
dm |= WriteOnly;
|
||||
if (o == "br" || o == "blockr" || o == "blockread" || o == "blockingread")
|
||||
op |= BlockingRead;
|
||||
if (o == "bw" || o == "blockw" || o == "blockwrite" || o == "blockingwrite")
|
||||
op |= BlockingRead;
|
||||
if (o == "brw" || o == "bwr" || o == "blockrw" || o == "blockwr" || o == "blockreadrite" || o == "blockingreadwrite")
|
||||
op |= BlockingRead | BlockingWrite;
|
||||
}
|
||||
fpwm.cutRight(fpwm.length() - fpwm.findLast("(")).trim();
|
||||
}
|
||||
if (dm == 0) dm = ReadWrite;
|
||||
if (full_path) *full_path = fpwm;
|
||||
if (mode) *mode = (DeviceMode)dm;
|
||||
if (opts) *opts = op;
|
||||
}
|
||||
|
||||
|
||||
PIString PIIODevice::fullPathOptions() const {
|
||||
if (mode_ == ReadWrite && options_ == 0) return PIString();
|
||||
PIString ret(" (");
|
||||
bool f = true;
|
||||
if (mode_ == ReadOnly) {if (!f) ret += ","; f = false; ret += "ro";}
|
||||
if (mode_ == WriteOnly) {if (!f) ret += ","; f = false; ret += "wo";}
|
||||
if (options_[BlockingRead]) {if (!f) ret += ","; f = false; ret += "br";}
|
||||
if (options_[BlockingWrite]) {if (!f) ret += ","; f = false; ret += "bw";}
|
||||
return ret + ")";
|
||||
}
|
||||
|
||||
|
||||
PIIODevice * PIIODevice::createFromFullPath(const PIString & full_path) {
|
||||
PIString prefix = full_path.left(full_path.find(":"));
|
||||
if (prefix.isEmpty()) return 0;
|
||||
@@ -306,15 +377,10 @@ PIString PIIODevice::normalizeFullPath(const PIString & full_path) {
|
||||
PIString ret = nfp_cache.value(full_path);
|
||||
if (!ret.isEmpty())
|
||||
return ret;
|
||||
//piCout << "normalizeFullPath" << full_path;
|
||||
PIString fp; PIIODevice::DeviceMode md;
|
||||
PIConnection::splitFullPathWithMode(full_path, &fp, &md);
|
||||
PIIODevice * d = createFromFullPath(fp);
|
||||
PIIODevice * d = createFromFullPath(full_path);
|
||||
//piCout << "normalizeFullPath" << d;
|
||||
if (d == 0) return PIString();
|
||||
ret = d->constructFullPath();
|
||||
if (md == PIIODevice::ReadOnly) ret += " (ro)";
|
||||
if (md == PIIODevice::WriteOnly) ret += " (wo)";
|
||||
delete d;
|
||||
nfp_cache[full_path] = ret;
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user