home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
custfileut.tcl
< prev
next >
Wrap
Text File
|
1996-11-15
|
5KB
|
174 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1996
#
# File: @(#)custfileut.tcl /main/hindenburg/3
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)custfileut.tcl /main/hindenburg/3 15 Nov 1996 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]} {
if {"[path_name file $name]" != "$name"} {
set custF [path_name concat \
[path_name concat [m4_var get M4_home] $subDir] $name $type \
]
if {! [file exists $custF]} {
return ""
}
} elseif [catch {set custF [m4_path_name $subDir $name.$type]}] {
resetErrorVars
return ""
}
} 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 {
{mnu objtype opendefs openlocs propdefs proplocs tcl vie} {
set initContents 0
}
default {
case "$name" in {
{"" m4env} {
set initContents 0
}
default {
set initContents 1
}
}
}
}
if {"$lvlObj" == ""} {
set custF [path_name concat [path_name concat ~ icase] $name $type]
set crntPath [pwd]
cd [path_name directory $custF]
BasicFS::makeFile [path_name file $custF]
cd $crntPath
# 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 \
[path_name concat [m4_var get M4_home] $subDir] $name $type \
]
set crntPath [pwd]
cd [path_name directory $custF]
BasicFS::makeFile [path_name file $custF]
cd $crntPath
} 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