summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-03-03 22:42:06 +0000
committerKarl Berry <karl@freefriends.org>2024-03-03 22:42:06 +0000
commitf67d516ae89332c63ae31106fd6d422d1e3de291 (patch)
tree61431e0bdbaa674b61131dd98d502a33c2d80e13 /Build
parentb676996d2a64c317018c5080c5681294b65f3dcc (diff)
update some sources and their READMEs for TL24; move wtestopenfiles to windows_wrapper; freeglut.dll no longer needed for asy
git-svn-id: svn://tug.org/texlive/trunk@70384 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/texlive/windows_wrapper/wtestopenfiles.README13
-rw-r--r--Build/source/texk/texlive/windows_wrapper/wtestopenfiles.c72
2 files changed, 85 insertions, 0 deletions
diff --git a/Build/source/texk/texlive/windows_wrapper/wtestopenfiles.README b/Build/source/texk/texlive/windows_wrapper/wtestopenfiles.README
new file mode 100644
index 00000000000..263dda584ce
--- /dev/null
+++ b/Build/source/texk/texlive/windows_wrapper/wtestopenfiles.README
@@ -0,0 +1,13 @@
+This program can be used to prevent doomed TeX Live update attempts
+on windows by testing whether all files concerned can be opened with
+exclusive read/write access.
+
+It reads a list of absolute filepaths from stdin and errors out if
+any of them cannot be opened with exclusive read/write access.
+
+A -v option also produces status output on stdout.
+
+Cross-compiling under linux:
+
+ i686-w64-mingw32-gcc -o wtestopenfiles.exe wtestopenfiles.c
+ i686-w64-mingw32-strip wtestopenfiles.exe
diff --git a/Build/source/texk/texlive/windows_wrapper/wtestopenfiles.c b/Build/source/texk/texlive/windows_wrapper/wtestopenfiles.c
new file mode 100644
index 00000000000..9570f8ccdd4
--- /dev/null
+++ b/Build/source/texk/texlive/windows_wrapper/wtestopenfiles.c
@@ -0,0 +1,72 @@
+/***********************************************************
+
+ This program tries to prevent doomed update attempts on windows by testing
+ whether all files concerned can be opened with exclusive read/write access.
+
+ This file is written in 2022 by Siep Kroonenberg and is placed
+ in the Public Domain.
+
+***********************************************************/
+
+#include <windows.h>
+#include <stdio.h>
+
+int main( int argc, char *argv[] ) {
+ HANDLE hf;
+ char buf[MAX_PATH];
+ int ok = 1;
+ int chatty = 0;
+ int i;
+
+ if( argc > 1 ) {
+ for( i=1;i<argc;i++ ) {
+ if( argv[i][1] == 'v' ) {
+ chatty = 1;
+ } else {
+ puts( "This program reads a list of absolute filepaths from stdin" );
+ puts( "and errors out if any of them cannot be opened with" );
+ puts( "exclusive read/write access." );
+ puts( "A -v option produces status output on stdout." );
+ exit( 1 );
+ }
+ }
+ }
+
+ while ( fgets( buf, MAX_PATH, stdin )) {
+ buf[strlen(buf)-1] = '\0';
+ if (buf[0] != '\0') {
+ // buf represents a filepath
+ hf = CreateFile(
+ buf,
+ GENERIC_READ | GENERIC_WRITE,
+ 0, // not shared
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL
+ );
+ // OPEN_ALWAYS: creates missing file
+ // OPEN_EXISTING: can fail with ERROR_FILE_NOT_FOUND
+ if( hf == INVALID_HANDLE_VALUE ) {
+ if( GetLastError() == ERROR_FILE_NOT_FOUND ) {
+ if( chatty ) printf( "%s not present, is ok\n", buf );
+ continue;
+ } else {
+ ok = 0;
+ if( chatty ) printf( "%s present, but cannot be opened\n", buf );
+ break;
+ }
+ } else {
+ if( chatty ) printf( "%s can be exclusively opened, is ok\n", buf );
+ CloseHandle( hf );
+ }
+ }
+ }
+ if( ok ) {
+ if( chatty ) puts( "ok" );
+ exit(0);
+ } else {
+ if( chatty ) puts( "not ok" );
+ exit( 1 );
+ }
+}