test and get reading schematics from the web on Windows working

This commit is contained in:
stefan schippers 2022-11-18 16:06:06 +01:00
parent 4d3ede661a
commit 9c31682517
3 changed files with 21 additions and 4 deletions

View File

@ -337,6 +337,13 @@ set editor {notepad.exe}
# lappend tcl_files ${XSCHEM_SHAREDIR}/change_index.tcl
# lappend tcl_files ${XSCHEM_SHAREDIR}/ngspice_backannotate.tcl
###########################################################################
#### WEB URL DOWNLOAD HELPER APPLICATION
###########################################################################
#### used to download files from web: default: {curl -f -s -O}
# set download_url_helper {curl -f -s -O}
# set download_url_helper {wget -N --quiet}
###########################################################################
#### XSCHEM TOOLBAR
###########################################################################

View File

@ -2180,7 +2180,9 @@ void load_schematic(int load_symbols, const char *fname, int reset_undo) /* 2015
} else if((strstr(xctx->current_dirname, "http://") == xctx->current_dirname ||
strstr(xctx->current_dirname, "https://") == xctx->current_dirname)) {
/* ... but not local file from web download --> reset current_dirname */
if(strstr(filename, "/tmp/xschem_web") != filename) {
char sympath[PATH_MAX];
my_snprintf(sympath, S(sympath), "%s/xschem_web", tclgetvar("XSCHEM_TMP_DIR"));
if(strstr(filename, sympath) != filename) {
my_snprintf(msg, S(msg), "regsub {/\\.$} [get_directory {%s}] {}", filename);
my_strncpy(xctx->current_dirname, tcleval(msg), S(xctx->current_dirname));
}

View File

@ -2461,12 +2461,15 @@ proc myload_set_home {dir} {
}
proc setglob {dir} {
global myload_globfilter myload_files2
global myload_globfilter myload_files2 OS
set myload_files2 [lsort [glob -nocomplain -directory $dir -tails -type d .* *]]
if { $myload_globfilter eq {*}} {
set myload_files2 ${myload_files2}\ [lsort [
glob -nocomplain -directory $dir -tails -type {f} .* $myload_globfilter]]
} else {
if {$OS == "Windows"} {
regsub {:} $myload_globfilter {\:} myload_globfilter
}
set myload_files2 ${myload_files2}\ [lsort [
glob -nocomplain -directory $dir -tails -type {f} $myload_globfilter]]
}
@ -4435,11 +4438,16 @@ proc get_directory {f} {
# fetch a remote url into ${XSCHEM_TMP_DIR}/xschem_web
proc download_url {url} {
global XSCHEM_TMP_DIR download_url_helper
global XSCHEM_TMP_DIR download_url_helper OS
if {![file exists ${XSCHEM_TMP_DIR}/xschem_web]} {
file mkdir ${XSCHEM_TMP_DIR}/xschem_web
}
set r [catch {exec sh -c "cd ${XSCHEM_TMP_DIR}/xschem_web; $download_url_helper $url"} res]
if {$OS eq "Windows"} {
set cmd "cmd /c \"cd ${XSCHEM_TMP_DIR}/xschem_web & $download_url_helper $url\""
set r [catch {eval exec $cmd } res]
} else {
set r [catch {exec sh -c "cd ${XSCHEM_TMP_DIR}/xschem_web; $download_url_helper $url"} res]
}
# puts "download_url: url=$url, exit code=$r, res=$res"
return $r
}