home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
custfileut.tcl
< prev
next >
Wrap
Text File
|
1997-10-07
|
4KB
|
157 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1996
#
# File: @(#)custfileut.tcl /main/titanic/9
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)custfileut.tcl /main/titanic/9 7 Oct 1997 Copyright 1996 Cadre Technologies Inc.
# Start user added include file section
# End user added include file section
Class CustFileUtilities : {Object} {
constructor
method destructor
}
constructor CustFileUtilities {class this name} {
set this [Object::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method CustFileUtilities::destructor {this} {
# Start destructor user section
# End destructor user section
}
proc CustFileUtilities::find {lvlObj name type {subDir etc}} {
if {"$lvlObj" == ""} {
set custF [path_name concat [path_name concat ~ icase] $name $type]
if {! [file exists $custF]} {
return ""
}
} elseif {[$lvlObj isA Corporate]} {
set custF [path_name concat \
[path_name concat [m4_var get M4_home] $subDir] $name $type \
]
if {! [file exists $custF]} {
if [catch {set custF [m4_path_name $subDir $name.$type]}] {
resetErrorVars
}
}
} else {
set custF [$lvlObj findCustomFileVersion $name $type]
if [$custF isNil] {
return ""
}
}
return $custF
}
proc CustFileUtilities::read {lvlObj name type {subDir etc}} {
set custF [CustFileUtilities::find $lvlObj $name $type $subDir]
if {"$custF" == ""} return
if {"$lvlObj" == "" || [$lvlObj isA Corporate]} {
source $custF
} else {
set tmpFile [args_file {}]
$custF downLoad $tmpFile
source $tmpFile
unlink $tmpFile
}
}
proc CustFileUtilities::save {tmpFile lvlObj name type {subDir etc}} {
set custF [CustFileUtilities::find $lvlObj $name $type $subDir]
if {"$custF" == ""} return
if {"$lvlObj" == "" || [$lvlObj isA Corporate]} {
copy_text_file $tmpFile $custF
} else {
$custF upLoad $tmpFile
}
}
proc CustFileUtilities::make {lvlObj name type {subDir etc}} {
# Check whether contents should be initialized or not
case "$type" in {
{pnl roundtrip copyspecs userroles roles} {
set initContents 1
}
default {
set initContents 0
}
}
if {"$lvlObj" == ""} {
set icaseDir [location [M4Login::getHomeDir] "icase"]
set custF [path_name concat $icaseDir $name $type]
BasicFS::makeFile $custF
# Initialize contents
set cc [ClientContext::global]
if {$initContents && [$cc customFileExists $name $type $subDir]} {
set tmpFile [args_file {}]
$cc downLoadCustomFile $name $type $subDir $tmpFile
copy_text_file $tmpFile $custF
unlink $tmpFile
}
} elseif {[$lvlObj isA Corporate]} {
set custF [path_name concat [location [m4_var get M4_home] \
$subDir] $name $type]
BasicFS::makeFile $custF
} else {
# Initialize contents
set cc [ClientContext::global]
set tmpFileExists 0
if {$initContents && [$cc customFileExists $name $type $subDir]} {
set tmpFile [args_file {}]
set tmpFileExists 1
$cc downLoadCustomFile $name $type $subDir $tmpFile
}
set custF [$lvlObj createCustomFileVersion $name $type]
if $tmpFileExists {
$custF edit
$custF upLoad $tmpFile
$custF quit
unlink $tmpFile
}
}
return $custF
}
proc CustFileUtilities::contents {lvlObj name type {subDir etc}} {
set custF [CustFileUtilities::find $lvlObj $name $type $subDir]
if {"$custF" == ""} {
return {0 ""}
}
set tmpFileExists 0
if {"$lvlObj" == "" || [$lvlObj isA Corporate]} {
set fid [open $custF]
} else {
set tmpFile [args_file {}]
set tmpFileExists 1
$custF downLoad $tmpFile
set fid [open $tmpFile]
}
set contents [read -nonewline $fid]
close $fid
if $tmpFileExists {
unlink $tmpFile
}
return [list 1 "$contents"]
}
# Do not delete this line -- regeneration end marker