summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/support/texosquery/CHANGES27
-rw-r--r--Master/texmf-dist/doc/support/texosquery/texosquery.pdfbin247702 -> 251370 bytes
-rwxr-xr-xMaster/texmf-dist/scripts/texosquery/texosquery.jarbin6548 -> 6773 bytes
-rw-r--r--Master/texmf-dist/source/support/texosquery/TeXOSQuery.java1374
-rw-r--r--Master/texmf-dist/source/support/texosquery/texosquery.dtx161
-rw-r--r--Master/texmf-dist/tex/latex/texosquery/texosquery.sty2
-rw-r--r--Master/texmf-dist/tex/latex/texosquery/texosquery.tex29
7 files changed, 916 insertions, 677 deletions
diff --git a/Master/texmf-dist/doc/support/texosquery/CHANGES b/Master/texmf-dist/doc/support/texosquery/CHANGES
new file mode 100644
index 00000000000..86ae40b460c
--- /dev/null
+++ b/Master/texmf-dist/doc/support/texosquery/CHANGES
@@ -0,0 +1,27 @@
+1.1 (2016-07-14):
+
+ * texosquery.jar:
+
+ - Added --dirname (-e)
+
+ - Multiline results add braces to each line
+ (to make it easier to parse the results in TeX).
+
+ - Code refactored.
+
+ - Code now compiled for Java 5 to support users with
+ old versions of the JRE.
+
+ * texosquery.tex:
+
+ - \TeXOSQueryNow and \TeXOSQueryFileDate set the category
+ code of D to 12 (to match \pdfcreationdate).
+
+ - new command \TeXOSQueryDirName
+
+ - dry run mode is now by default on unless shell escape=1
+ (unrestricted mode)
+
+1.0 (2016-07-08):
+
+ * Initial release
diff --git a/Master/texmf-dist/doc/support/texosquery/texosquery.pdf b/Master/texmf-dist/doc/support/texosquery/texosquery.pdf
index 49c5401edbe..7471094188a 100644
--- a/Master/texmf-dist/doc/support/texosquery/texosquery.pdf
+++ b/Master/texmf-dist/doc/support/texosquery/texosquery.pdf
Binary files differ
diff --git a/Master/texmf-dist/scripts/texosquery/texosquery.jar b/Master/texmf-dist/scripts/texosquery/texosquery.jar
index d56b681bbe1..84f4c1140a2 100755
--- a/Master/texmf-dist/scripts/texosquery/texosquery.jar
+++ b/Master/texmf-dist/scripts/texosquery/texosquery.jar
Binary files differ
diff --git a/Master/texmf-dist/source/support/texosquery/TeXOSQuery.java b/Master/texmf-dist/source/support/texosquery/TeXOSQuery.java
index 6b4f2a5c715..dca8fa7c32d 100644
--- a/Master/texmf-dist/source/support/texosquery/TeXOSQuery.java
+++ b/Master/texmf-dist/source/support/texosquery/TeXOSQuery.java
@@ -1,681 +1,767 @@
package com.dickimawbooks.texosquery;
+import java.io.BufferedReader;
import java.util.Locale;
import java.util.Calendar;
-import java.io.*;
-
-public class TeXOSQuery
-{
- public static String escapeHash(String str)
- {
- return str.replaceAll("#", "\\\\#");
- }
-
- public static String getLocale(Locale locale)
- {
- return getLocale(locale, false);
- }
-
- public static String getLocale(Locale locale, boolean convertCodeset)
- {
- String id = "";
-
- if (locale != null)
- {
- String lang = locale.getLanguage();
-
- if (lang != null)
- {
- id = lang;
- }
-
- String country = locale.getCountry();
-
- if (country != null && !country.isEmpty())
- {
- if (id.isEmpty())
- {
- id = country;
- }
- else
- {
- id = id+"-"+country;
- }
- }
-
- String codeset = System.getProperty("file.encoding");
-
- if (codeset != null && !codeset.isEmpty())
- {
- if (convertCodeset)
- {
- codeset = codeset.toLowerCase().replaceAll("-", "");
- }
-
- id = id+"."+codeset;
- }
-
- String script = locale.getScript();
-
- if (script != null && !script.isEmpty())
- {
- id = id+"@"+escapeHash(script);
- }
-
- }
-
- return id;
- }
-
- public static String getOSname()
- {
- try
- {
- return escapeHash(System.getProperty("os.name", ""));
- }
- catch (SecurityException e)
- {
- return "";
- }
- }
-
- public static String getOSarch()
- {
- try
- {
- return escapeHash(System.getProperty("os.arch", ""));
- }
- catch (SecurityException e)
- {
- return "";
- }
- }
-
- public static String getOSversion()
- {
- try
- {
- return escapeHash(System.getProperty("os.version", ""));
- }
- catch (SecurityException e)
- {
- return "";
- }
- }
-
- public static String getUserHome()
- {
- try
- {
- return toTeXPath(System.getProperty("user.home", ""));
- }
- catch (SecurityException e)
- {
- return "";
- }
- }
-
- /*
- * Since this is designed to work within TeX, backslashes in paths
- * need to be replaced with forward slashes.
- */
-
- public static String toTeXPath(String filename)
- {
- if (filename == null)
- {
- return "";
- }
-
- if (File.separatorChar == '\\')
- {
- filename = filename.replaceAll("\\\\", "/");
- }
-
- return escapeHash(filename);
- }
-
- public static String fromTeXPath(String filename)
- {
- if (File.separatorChar != '/')
- {
- return filename.replaceAll("/", File.separator);
- }
-
- return filename;
- }
-
- public static File fileFromTeXPath(String filename)
- {
- filename = fromTeXPath(filename);
-
- File file = new File(filename);
-
- if (!file.exists() && file.getParent() == null)
- {
- // use kpsewhich to find it
-
- try
- {
- Process p = new ProcessBuilder("kpsewhich", filename).start();
-
- if (p.waitFor() == 0)
- {
- InputStream is = p.getInputStream();
-
- if (is != null)
- {
- BufferedReader in = new BufferedReader(
- new InputStreamReader(is));
-
- String line = in.readLine();
-
- in.close();
-
- if (line != null && !line.isEmpty())
- {
- file = new File(fromTeXPath(line));
- }
- }
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * Main class.
+ * @author Nicola Talbot
+ * @version 1.1
+ * @since 1.0
+ */
+public class TeXOSQuery {
+
+ private static final String VERSION_NUMBER = "1.1";
+ private static final String VERSION_DATE = "2016-07-14";
+ private static final char BACKSLASH = '\\';
+ private static final char FORWARDSLASH = '/';
+ private static final long ZERO = 0L;
+
+ /**
+ * Escapes hash from input string.
+ * @param string Input string.
+ * @return String with hash escaped.
+ */
+ private static String escapeHash(String string) {
+ return string.replaceAll("#", "\\\\#");
+ }
+
+ /**
+ * Gets a string representation of the provided locale.
+ * @param locale The provided locale.
+ * @return String representation.
+ */
+ private static String getLocale(Locale locale) {
+ return getLocale(locale, false);
+ }
+
+ /**
+ * Gets a string representation of the provided locale, converting the code
+ * set if possible.
+ * @param locale The provided locale.
+ * @param convertCodeset Boolean value to convert the code set.
+ * @return String representation.
+ */
+ private static String getLocale(Locale locale, boolean convertCodeset) {
+
+ String identifier = "";
+
+ if (locale != null) {
+
+ String language = locale.getLanguage();
+
+ if (language != null) {
+ identifier = language;
}
- }
- catch (IOException e)
- {
- }
- catch (InterruptedException e)
- {
- }
- }
-
- return file;
- }
-
- public static String getCwd()
- {
- try
- {
- return toTeXPath(System.getProperty("user.dir", ""));
- }
- catch (SecurityException e)
- {
- return "";
- }
- }
-
- public static String getTmpDir()
- {
- try
- {
- return toTeXPath(System.getProperty("java.io.tmpdir", ""));
- }
- catch (SecurityException e)
- {
- return "";
- }
- }
-
- public static String pdfnow()
- {
- Calendar cal = Calendar.getInstance();
-
- return pdfDate(cal);
- }
-
- public static String pdfDate(Calendar cal)
- {
- String tz = String.format("%1$tz", cal);
-
- return String.format("D:%1$tY%1$tm%1td%1$tH%1$tM%1$tS%2$s'%3$s'", cal,
- tz.substring(0,3), tz.substring(3));
- }
-
- public static String pdfDate(File file)
- {
- try
- {
- long millisecs = file.lastModified();
-
- if (millisecs > 0L)
- {
- Calendar cal = Calendar.getInstance();
- cal.setTimeInMillis(millisecs);
-
- return pdfDate(cal);
- }
- }
- catch (SecurityException e)
- {
- }
-
- return "";
- }
-
- public static String getFileLength(File file)
- {
- try
- {
- long len = file.length();
-
- if (len > 0L)
- {
- return String.format("%d", len);
- }
- }
- catch (SecurityException e)
- {
- }
-
- return "";
- }
- public static String getFileList(String sep, File dir)
- {
- if (!dir.isDirectory())
- {
- return "";
- }
-
- StringBuilder builder = new StringBuilder();
-
- try
- {
- String[] list = dir.list();
-
- if (list == null)
- {
- return "";
- }
-
- for (int i = 0; i < list.length; i++)
- {
- if (i > 0)
- {
- builder.append(sep);
+ String country = locale.getCountry();
+
+ if ((country != null) &&
+ (!"".equals(country))) {
+
+ if ("".equals(identifier)) {
+ identifier = country;
+ } else {
+ identifier = identifier.concat("-").concat(country);
+ }
+
}
- // no need to worry about directory divider
- // File.list() just returns the name not the path
- builder.append(escapeHash(list[i]));
- }
- }
- catch (SecurityException e)
- {
- }
-
- return builder.toString();
- }
-
- public static String getFilterFileList(String sep,
- final String regex, File dir)
- {
- if (!dir.isDirectory())
- {
- return "";
- }
-
- if (regex == null || regex.isEmpty())
- {
- return getFileList(sep, dir);
- }
-
- StringBuilder builder = new StringBuilder();
-
- try
- {
- String[] list = dir.list(new FilenameFilter()
- {
- public boolean accept(File dir, String name)
- {
- return name.matches(regex);
- }
- });
+ String codeset = System.getProperty("file.encoding", "UTF-8");
- if (list == null)
- {
- return "";
- }
+ if ((codeset != null) &&
+ (!"".equals(codeset))) {
+
+ if (convertCodeset) {
+ codeset = codeset.toLowerCase().replaceAll("-", "");
+ }
- for (int i = 0; i < list.length; i++)
- {
- if (i > 0)
- {
- builder.append(sep);
+ identifier = identifier.concat(".").concat(codeset);
}
- // no need to worry about directory divider
- // File.list() just returns the name not the path
- builder.append(escapeHash(list[i]));
- }
- }
- catch (SecurityException e)
- {
- }
-
- return builder.toString();
- }
-
- public static String fileURI(File file)
- {
- if (!file.exists())
- {
- return "";
- }
-
- try
- {
- // don't worry about '#' as it would've been converted to
- // %23 (\TeXOSQuery changes the catcode of %)
- return file.toURI().toString();
- }
- catch (SecurityException e)
- {
- }
-
- return "";
- }
-
- public static String filePath(File file)
- {
- if (!file.exists())
- {
- return "";
- }
-
- try
- {
- return toTeXPath(file.getCanonicalPath());
- }
- catch (SecurityException e)
- {
- }
- catch (IOException e)
- {
- }
-
- return "";
- }
-
- public static void syntax()
- {
- System.out.println("Usage: texosquery <option>...");
-
- System.out.println();
- System.out.println("Cross-platform OS query application");
- System.out.println("for use with TeX's shell escape.");
- System.out.println();
- System.out.println("Each query displays the result in a single line.");
- System.out.println("A blank line is printed if the requested");
- System.out.println("information is unavailable.");
-
- System.out.println();
- System.out.println("-h or --help\tDisplay this help message and exit");
- System.out.println("-v or --version\tDisplay version information and exit");
- System.out.println();
- System.out.println("General:");
- System.out.println();
- System.out.println("-L or --locale\t\tDisplay locale information");
- System.out.println("-l or --locale-lcs\tAs --locale but codeset ");
- System.out.println("\t\t\tin lowercase with hyphens stripped");
- System.out.println("-c or --cwd\t\tDisplay current working directory");
- System.out.println("-m or --userhome\tDisplay user's home directory");
- System.out.println("-t or --tmpdir\t\tDisplay temporary directory");
- System.out.println("-o or --osname\t\tDisplay OS name");
- System.out.println("-r or --osversion\tDisplay OS version");
- System.out.println("-a or --osarch\t\tDisplay OS architecture");
- System.out.println("-n or --pdfnow\t\tDisplay current date-time in PDF format");
-
- System.out.println();
- System.out.println("File Queries:");
- System.out.println();
- System.out.println("Paths should use / for the directory divider.");
- System.out.println();
- System.out.println("-d <file> or --pdfdate <file>");
- System.out.println(" Display date stamp of <file> in PDF format");
- System.out.println();
- System.out.println("-s <file> or --filesize <file>");
- System.out.println(" Display size of <file> in bytes");
- System.out.println();
- System.out.println("-i <sep> <dir> or --list <sep> <dir>");
- System.out.println(" Display list of all files in <dir> separated by <sep>");
- System.out.println();
- System.out.println("-f <sep> <regex> <dir> or --filterlist <sep> <regex> <dir>");
- System.out.println(" Display list of files in <dir> that match <regex> separated by <sep>");
- System.out.println();
- System.out.println("-u <file> or --uri <file>");
- System.out.println(" Display the URI of <file>");
- System.out.println();
- System.out.println("-p <file> or --path <file>");
- System.out.println(" Display the canonical path of <file>");
-
- }
-
- public static void version()
- {
- System.out.println(String.format("texosquery %s %s", versionNum,
- versionDate));
- System.out.println("Copyright 2016 Nicola Talbot");
- System.out.println("License LPPL 1.3+ (http://ctan.org/license/lppl1.3)");
- }
-
- public static void main(String[] args)
- {
- if (args.length == 0)
- {
- System.err.println("Missing argument. Try texosquery --help");
- System.exit(1);
- }
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].equals("-L") || args[i].equals("--locale"))
- {
- System.out.println(getLocale(Locale.getDefault()));
- }
- else if (args[i].equals("-l") || args[i].equals("--locale-lcs"))
- {
- System.out.println(getLocale(Locale.getDefault(), true));
- }
- else if (args[i].equals("-c") || args[i].equals("--cwd"))
- {
- System.out.println(getCwd());
- }
- else if (args[i].equals("-m") || args[i].equals("--userhome"))
- {
- System.out.println(getUserHome());
- }
- else if (args[i].equals("-t") || args[i].equals("--tmpdir"))
- {
- System.out.println(getTmpDir());
- }
- else if (args[i].equals("-r") || args[i].equals("--osversion"))
- {
- System.out.println(getOSversion());
- }
- else if (args[i].equals("-a") || args[i].equals("--osarch"))
- {
- System.out.println(getOSarch());
- }
- else if (args[i].equals("-o") || args[i].equals("--osname"))
- {
- System.out.println(getOSname());
- }
- else if (args[i].equals("-n") || args[i].equals("--pdfnow"))
- {
- System.out.println(pdfnow());
- }
- else if (args[i].equals("-d") || args[i].equals("--pdfdate"))
- {
- i++;
-
- if (i >= args.length)
- {
- System.err.println(
- String.format("filename expected after %s", args[i-1]));
- System.exit(1);
- }
+ String script = locale.getScript();
- if (args[i].isEmpty())
- {
- System.out.println();
- }
- else
- {
- System.out.println(pdfDate(fileFromTeXPath(args[i])));
+ if ((script != null) &&
+ (!"".equals(script))) {
+ identifier = identifier.concat("@").concat(escapeHash(script));
}
- }
- else if (args[i].equals("-s") || args[i].equals("--filesize"))
- {
- i++;
- if (i >= args.length)
- {
- System.err.println(
- String.format("filename expected after %s", args[i-1]));
- System.exit(1);
+ }
+
+ return identifier;
+ }
+
+ /**
+ * Gets the OS name.
+ * @return The OS name as string.
+ */
+ private static String getOSname() {
+ return getSystemProperty("os.name");
+ }
+
+ /**
+ * Gets the OS architecture.
+ * @return The OS architecture as string.
+ */
+ private static String getOSarch() {
+ return getSystemProperty("os.arch");
+ }
+
+ /**
+ * Gets the OS version.
+ * @return The OS version as string.
+ */
+ private static String getOSversion() {
+ return getSystemProperty("os.version");
+ }
+
+ /**
+ * Gets the user home.
+ * @return The user home as string.
+ */
+ private static String getUserHome() {
+ return getSystemProperty("user.home");
+ }
+
+ /*
+ *
+ */
+ /**
+ * Converts the filename string to TeX path. Since this is designed to work
+ * within TeX, backslashes in paths need to be replaced with forward
+ * slashes.
+ * @param filename The filename string.
+ * @return TeX path.
+ */
+ private static String toTeXPath(String filename) {
+
+ String path = "";
+
+ if (filename != null) {
+ if (File.separatorChar == BACKSLASH) {
+ filename = filename.replaceAll("\\\\", "/");
}
-
- if (args[i].isEmpty())
- {
- System.out.println();
+ path = escapeHash(filename);
+ }
+
+ return path;
+ }
+
+ /**
+ * Converts the TeX path back to the original representation.
+ * @param filename The filename string.
+ * @return The original representation.
+ */
+ private static String fromTeXPath(String filename) {
+
+ if (File.separatorChar != FORWARDSLASH) {
+ filename = filename.replaceAll("/", File.separator);
+ }
+
+ return filename;
+ }
+
+ /**
+ * Gets a file representation from a filename string.
+ * @param filename Filename string.
+ * @return File representation
+ */
+ private static File fileFromTeXPath(String filename) {
+
+ filename = fromTeXPath(filename);
+ File file = new File(filename);
+
+ if (!file.exists() && file.getParent() == null) {
+
+ try {
+ Process process = new ProcessBuilder(
+ "kpsewhich",
+ filename
+ ).start();
+
+ if (process.waitFor() == 0) {
+
+ InputStream stream = process.getInputStream();
+
+ if (stream != null) {
+
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(stream)
+ );
+
+ String line = reader.readLine();
+ reader.close();
+
+ if ((line != null) && (!"".equals(line))) {
+ file = new File(fromTeXPath(line));
+ }
+ }
+ }
+ } catch (IOException exception1) {
+ // quack quack
+ } catch (InterruptedException exception2) {
+ // quack quack
}
- else
- {
- System.out.println(getFileLength(fileFromTeXPath(args[i])));
+ }
+
+ return file;
+ }
+
+ /**
+ * Gets the current working directory.
+ * @return The current working directory.
+ */
+ private static String getCwd() {
+ return getSystemProperty("user.dir");
+ }
+
+ /**
+ * Gets the temporary directory.
+ * @return Temporary directory.
+ */
+ private static String getTmpDir() {
+ return getSystemProperty("java.io.tmpdir");
+ }
+
+ /**
+ * Gets the current date.
+ * @return The current date.
+ */
+ private static String pdfnow() {
+ return pdfDate(Calendar.getInstance());
+ }
+
+ /**
+ * Gets the date in an specific format.
+ * @param calendar A calendar object.
+ * @return Date in an specific format.
+ */
+ private static String pdfDate(Calendar calendar) {
+ String tz = String.format("%1$tz", calendar);
+ return String.format(
+ "D:%1$tY%1$tm%1td%1$tH%1$tM%1$tS%2$s'%3$s'",
+ calendar,
+ tz.substring(0, 3),
+ tz.substring(3)
+ );
+ }
+
+ /**
+ * Gets the date from a file.
+ * @param file File.
+ * @return The date in an specific format.
+ */
+ private static String pdfDate(File file) {
+
+ String date = "";
+
+ try {
+ long millisecs = file.lastModified();
+
+ if (millisecs > ZERO) {
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(millisecs);
+ date = pdfDate(calendar);
+
}
- }
- else if (args[i].equals("-i") || args[i].equals("--list"))
- {
- i++;
-
- if (i >= args.length)
- {
- System.err.println(
- String.format("separator and directory name expected after %s",
- args[i-1]));
- System.exit(1);
+ } catch (SecurityException exception) {
+ // quack quack
+ }
+
+ return date;
+ }
+
+ /**
+ * Gets the file length.
+ * @param file The file.
+ * @return The length as a string.
+ */
+ private static String getFileLength(File file) {
+
+ String output = "";
+
+ try {
+ long length = file.length();
+
+ if (length > ZERO) {
+ output = String.format("%d", length);
}
-
- i++;
-
- if (i >= args.length)
- {
- System.err.println(
- String.format("directory name expected after %s %s",
- args[i-2], args[i-1]));
- System.exit(1);
+ } catch (SecurityException exception) {
+ // quack quack
+ }
+
+ return output;
+ }
+
+ /**
+ * Gets the list of files from a directory.
+ * @param separator Separator.
+ * @param directory Directory.
+ * @return List as a string.
+ */
+ private static String getFileList(String separator, File directory) {
+
+ StringBuilder builder = new StringBuilder();
+
+ if (directory.isDirectory()) {
+
+ try {
+
+ String[] list = directory.list();
+ if (list != null) {
+
+ for (int i = 0; i < list.length; i++) {
+
+ if (i > 0) {
+ builder.append(separator);
+ }
+
+ builder.append(escapeHash(list[i]));
+
+ }
+ }
+
+ } catch (SecurityException exception) {
+ // quack quack
}
-
- if (args[i].isEmpty())
- {
- System.out.println();
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Gets a filtered list of files from directory.
+ * @param separator Separator.
+ * @param regex Regular expression.
+ * @param directory Directory.
+ * @return Filtered list as string.
+ */
+ private static String getFilterFileList(String separator,
+ final String regex, File directory) {
+
+ StringBuilder builder = new StringBuilder();
+
+ if (directory.isDirectory()) {
+
+ if ((regex == null) || ("".equals(regex))) {
+ builder.append(getFileList(separator, directory));
}
- else
- {
- System.out.println(getFileList(args[i-1],
- new File(fromTeXPath(args[i]))));
+ else {
+ try {
+ String[] list = directory.list(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.matches(regex);
+ }
+ });
+
+ if (list != null) {
+
+ for (int i = 0; i < list.length; i++) {
+
+ if (i > 0) {
+ builder.append(separator);
+ }
+
+ builder.append(escapeHash(list[i]));
+ }
+
+ }
+ } catch (SecurityException exception) {
+ // quack quack
+ }
}
- }
- else if (args[i].equals("-f") || args[i].equals("--filterlist"))
- {
- i++;
-
- if (i >= args.length)
- {
- System.err.println(
- String.format(
- "separator, regex and directory name expected after %s",
- args[i-1]));
- System.exit(1);
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Gets the file URI.
+ * @param file The file.
+ * @return The URI.
+ */
+ private static String fileURI(File file) {
+
+ String uri = "";
+
+ if (file.exists()) {
+ try {
+ uri = file.toURI().toString();
+ } catch (SecurityException exception) {
+ // quack quack
}
-
- i++;
-
- if (i >= args.length)
- {
- System.err.println(
- String.format("regex and directory name expected after %s %s",
- args[i-2], args[i-1]));
- System.exit(1);
+ }
+
+ return uri;
+ }
+
+ /**
+ * Gets the file path.
+ * @param file The file.
+ * @return The path.
+ */
+ private static String filePath(File file) {
+
+ String path = "";
+
+ if (file.exists()) {
+ try {
+ path = toTeXPath(file.getCanonicalPath());
+ } catch (SecurityException exception1) {
+ // quack quack
+ } catch (IOException exception2) {
+ // quack quack
}
-
- i++;
-
- if (i >= args.length)
- {
- System.err.println(
- String.format("directory name expected after %s %s",
- args[i-3], args[i-2], args[i-1]));
- System.exit(1);
+ }
+
+ return path;
+ }
+
+ /**
+ * Gets the path for the file's parent.
+ * @param file The file.
+ * @return The path.
+ */
+ private static String parentPath(File file) {
+
+ String path = "";
+
+ if (file.exists()) {
+ try {
+ path = toTeXPath(file.getCanonicalFile().getParent());
+ } catch (SecurityException exception1) {
+ // quack quack
+ } catch (IOException exception2) {
+ // quack quack
}
+ }
+
+ return path;
+ }
+
+ /**
+ * Prints the syntax usage.
+ */
+ private static void syntax() {
+ System.out.println("Usage: texosquery <option>...");
+
+ System.out.println();
+ System.out.println("Cross-platform OS query application");
+ System.out.println("for use with TeX's shell escape.");
+ System.out.println();
+ System.out.println("Each query displays the result in a single line.");
+ System.out.println("A blank line is printed if the requested");
+ System.out.println("information is unavailable.");
+
+ System.out.println();
+ System.out.println("-h or --help\tDisplay this help message and exit");
+ System.out.println("-v or --version\tDisplay version information and exit");
+ System.out.println();
+ System.out.println("General:");
+ System.out.println();
+ System.out.println("-L or --locale\t\tDisplay locale information");
+ System.out.println("-l or --locale-lcs\tAs --locale but codeset ");
+ System.out.println("\t\t\tin lowercase with hyphens stripped");
+ System.out.println("-c or --cwd\t\tDisplay current working directory");
+ System.out.println("-m or --userhome\tDisplay user's home directory");
+ System.out.println("-t or --tmpdir\t\tDisplay temporary directory");
+ System.out.println("-o or --osname\t\tDisplay OS name");
+ System.out.println("-r or --osversion\tDisplay OS version");
+ System.out.println("-a or --osarch\t\tDisplay OS architecture");
+ System.out.println("-n or --pdfnow\t\tDisplay current date-time in PDF format");
+
+ System.out.println();
+ System.out.println("File Queries:");
+ System.out.println();
+ System.out.println("Paths should use / for the directory divider.");
+ System.out.println();
+ System.out.println("-d <file> or --pdfdate <file>");
+ System.out.println(" Display date stamp of <file> in PDF format");
+ System.out.println();
+ System.out.println("-s <file> or --filesize <file>");
+ System.out.println(" Display size of <file> in bytes");
+ System.out.println();
+ System.out.println("-i <sep> <dir> or --list <sep> <dir>");
+ System.out.println(" Display list of all files in <dir> separated by <sep>");
+ System.out.println();
+ System.out.println("-f <sep> <regex> <dir> or --filterlist <sep> <regex> <dir>");
+ System.out.println(" Display list of files in <dir> that match <regex> separated by <sep>");
+ System.out.println();
+ System.out.println("-u <file> or --uri <file>");
+ System.out.println(" Display the URI of <file>");
+ System.out.println();
+ System.out.println("-p <file> or --path <file>");
+ System.out.println(" Display the canonical path of <file>");
+ System.out.println();
+ System.out.println("-e <file> or --dirname <file>");
+ System.out.println(" Display the canonical path of the parent of <file>");
+ }
+
+ /**
+ * Prints the version.
+ */
+ private static void version() {
+ System.out.println(String.format("texosquery %s %s", VERSION_NUMBER,
+ VERSION_DATE));
+ System.out.println("Copyright 2016 Nicola Talbot");
+ System.out.println("License LPPL 1.3+ (http://ctan.org/license/lppl1.3)");
+ }
+
+ /**
+ * Prints the information with optional grouping.
+ * @param group Determines whether to add grouping
+ * @param info Information to print
+ */
+ private static void print(boolean group, String info)
+ {
+ if (group)
+ {
+ System.out.println(String.format("{%s}", info));
+ }
+ else
+ {
+ System.out.println(info);
+ }
+ }
- if (args[i].isEmpty())
- {
- System.out.println();
+ /**
+ * Main method.
+ * @param args Command line arguments.
+ */
+ public static void main(String[] args) {
+ if (args.length == 0) {
+ System.err.println("Missing argument. Try texosquery --help");
+ System.exit(1);
+ }
+
+ boolean group = false;
+
+ for (int i = 0, n=args.length-1; i < args.length; i++) {
+ if (args[i].equals("-L") || args[i].equals("--locale")) {
+ if (i < n) group = true;
+
+ print(group, getLocale(Locale.getDefault()));
+ } else if (args[i].equals("-l") || args[i].equals("--locale-lcs")) {
+ if (i < n) group = true;
+
+ print(group, getLocale(Locale.getDefault(), true));
+ } else if (args[i].equals("-c") || args[i].equals("--cwd")) {
+ if (i < n) group = true;
+
+ print(group, getCwd());
+ } else if (args[i].equals("-m") || args[i].equals("--userhome")) {
+ if (i < n) group = true;
+
+ print(group, getUserHome());
+ } else if (args[i].equals("-t") || args[i].equals("--tmpdir")) {
+ if (i < n) group = true;
+
+ print(group, getTmpDir());
+ } else if (args[i].equals("-r") || args[i].equals("--osversion")) {
+ if (i < n) group = true;
+
+ print(group, getOSversion());
+ } else if (args[i].equals("-a") || args[i].equals("--osarch")) {
+ if (i < n) group = true;
+
+ print(group, getOSarch());
+ } else if (args[i].equals("-o") || args[i].equals("--osname")) {
+ if (i < n) group = true;
+
+ print(group, getOSname());
+ } else if (args[i].equals("-n") || args[i].equals("--pdfnow")) {
+ if (i < n) group = true;
+
+ print(group, pdfnow());
+ } else if (args[i].equals("-d") || args[i].equals("--pdfdate")) {
+ i++;
+
+ if (i >= args.length) {
+ System.err.println(
+ String.format("filename expected after %s", args[i - 1]));
+ System.exit(1);
+ }
+
+ if (i < n) group = true;
+
+ if ("".equals(args[i])) {
+ print(group, "");
+ } else {
+ print(group, pdfDate(fileFromTeXPath(args[i])));
+ }
+ } else if (args[i].equals("-s") || args[i].equals("--filesize")) {
+ i++;
+
+ if (i >= args.length) {
+ System.err.println(
+ String.format("filename expected after %s", args[i - 1]));
+ System.exit(1);
+ }
+
+ if (i < n) group = true;
+
+ if ("".equals(args[i])) {
+ print(group, "");
+ } else {
+ print(group, getFileLength(fileFromTeXPath(args[i])));
+ }
+ } else if (args[i].equals("-i") || args[i].equals("--list")) {
+ i++;
+
+ if (i >= args.length) {
+ System.err.println(
+ String.format("separator and directory name expected after %s",
+ args[i - 1]));
+ System.exit(1);
+ }
+
+ i++;
+
+ if (i >= args.length) {
+ System.err.println(
+ String.format("directory name expected after %s %s",
+ args[i - 2], args[i - 1]));
+ System.exit(1);
+ }
+
+ if (i < n) group = true;
+
+ if ("".equals(args[i])) {
+ print(group, "");
+ } else {
+ print(group, getFileList(args[i - 1],
+ new File(fromTeXPath(args[i]))));
+ }
+ } else if (args[i].equals("-f") || args[i].equals("--filterlist")) {
+ i++;
+
+ if (i >= args.length) {
+ System.err.println(
+ String.format(
+ "separator, regex and directory name expected after %s",
+ args[i - 1]));
+ System.exit(1);
+ }
+
+ i++;
+
+ if (i >= args.length) {
+ System.err.println(
+ String.format("regex and directory name expected after %s %s",
+ args[i - 2], args[i - 1]));
+ System.exit(1);
+ }
+
+ i++;
+
+ if (i >= args.length) {
+ System.err.println(
+ String.format("directory name expected after %s %s",
+ args[i - 3], args[i - 2], args[i - 1]));
+ System.exit(1);
+ }
+
+ if (i < n) group = true;
+
+ if ("".equals(args[i])) {
+ print(group, "");
+ } else {
+ print(group, getFilterFileList(
+ args[i - 2], args[i - 1], new File(fromTeXPath(args[i]))));
+ }
+ } else if (args[i].equals("-u") || args[i].equals("--uri")) {
+ i++;
+
+ if (i >= args.length) {
+ System.err.println(
+ String.format("filename expected after %s", args[i - 1]));
+ System.exit(1);
+ }
+
+ if (i < n) group = true;
+
+ if ("".equals(args[i])) {
+ print(group, "");
+ } else {
+ print(group, fileURI(fileFromTeXPath(args[i])));
+ }
}
- else
+ else if (args[i].equals("-p") || args[i].equals("--path"))
{
- System.out.println(getFilterFileList(
- args[i-2], args[i-1], new File(fromTeXPath(args[i]))));
- }
- }
- else if (args[i].equals("-u") || args[i].equals("--uri"))
- {
- i++;
+ i++;
- if (i >= args.length)
- {
- System.err.println(
- String.format("filename expected after %s", args[i-1]));
- System.exit(1);
- }
+ if (i >= args.length) {
+ System.err.println(
+ String.format("filename expected after %s", args[i - 1]));
+ System.exit(1);
+ }
- if (args[i].isEmpty())
- {
- System.out.println();
- }
- else
- {
- System.out.println(fileURI(fileFromTeXPath(args[i])));
- }
- }
- else if (args[i].equals("-p") || args[i].equals("--path"))
- {
- i++;
+ if (i < n) group = true;
- if (i >= args.length)
- {
- System.err.println(
- String.format("filename expected after %s", args[i-1]));
- System.exit(1);
+ if ("".equals(args[i])) {
+ print(group, "");
+ } else {
+ print(group, filePath(fileFromTeXPath(args[i])));
+ }
}
-
- if (args[i].isEmpty())
+ else if (args[i].equals("-e") || args[i].equals("--dirname"))
{
- System.out.println();
+ i++;
+
+ if (i >= args.length) {
+ System.err.println(
+ String.format("filename expected after %s", args[i - 1]));
+ System.exit(1);
+ }
+
+ if (i < n) group = true;
+
+ if ("".equals(args[i])) {
+ print(group, "");
+ } else {
+ print(group,
+ parentPath(fileFromTeXPath(args[i])));
+ }
}
- else
- {
- System.out.println(filePath(fileFromTeXPath(args[i])));
+ else if (args[i].equals("-h") || args[i].equals("--help")) {
+ syntax();
+ System.exit(0);
+ } else if (args[i].equals("-v") || args[i].equals("--version")) {
+ version();
+ System.exit(0);
+ } else {
+ System.err.println(String.format("unknown option '%s'", args[i]));
+ System.exit(1);
}
- }
- else if (args[i].equals("-h") || args[i].equals("--help"))
- {
- syntax();
- System.exit(0);
- }
- else if (args[i].equals("-v") || args[i].equals("--version"))
- {
- version();
- System.exit(0);
- }
- else
- {
- System.err.println(String.format("unknown option '%s'", args[i]));
- System.exit(1);
- }
- }
- }
+ }
+ }
+
+ /**
+ * Gets the system property.
+ * @param key Key.
+ * @return Value;
+ */
+ private static String getSystemProperty(String key) {
+
+ String value = "";
+
+ try {
+ value = System.getProperty(key, "");
+ }
+ catch (SecurityException exception) {
+ // quack quack
+ }
+
+ return value;
+
+ }
- public static final String versionNum = "1.0";
- public static final String versionDate = "2016-07-08";
}
diff --git a/Master/texmf-dist/source/support/texosquery/texosquery.dtx b/Master/texmf-dist/source/support/texosquery/texosquery.dtx
index 35d3afc97cb..feda90f8680 100644
--- a/Master/texmf-dist/source/support/texosquery/texosquery.dtx
+++ b/Master/texmf-dist/source/support/texosquery/texosquery.dtx
@@ -30,7 +30,7 @@
\usepackage{metalogo}
\usepackage[colorlinks,hyperindex=false]{hyperref}
-\CheckSum{234}
+\CheckSum{269}
\RecordChanges
\PageIndex
@@ -61,8 +61,10 @@
%\DeleteShortVerb{|}
%
%\title{texosquery: query OS information from \TeX}
-%\author{Nicola L. C. Talbot\\\url{http://www.dickimaw-books.com/}}
-%\date{2016-07-08 (v1.0)}
+%\author{Nicola L. C. Talbot\\
+%\href{http://www.dickimaw-books.com/}{\nolinkurl{dickimaw-books.com}}
+%\and Paulo Cereda}
+%\date{2016-07-14 (v1.1)}
%\maketitle
%
%\begin{abstract}
@@ -81,6 +83,10 @@
%installed to use \texttt{texosquery}.
%\end{important}
%
+%If you want to rebuild the application, instructions for
+%compiling the source code (including the code for this document)
+%are in the accompanying \texttt{README.md} file.
+%
%\tableofcontents
%
%\section{texosquery.jar: the Java application}
@@ -99,10 +105,11 @@
%
%Since the application is designed to work with \TeX, each
%function will display the result on a single line without
-%formatting. A blank line will be displayed if the information
-%isn't available. A forward slash is always used as a
-%directory divider, regardless of the operating system, so
-%the result can be used, for example, in \cs{input} or
+%formatting. (For multiple results, each line is grouped
+%from v1.1.) A blank line (or empty group) will be displayed
+%if the information isn't available. A forward slash is always
+%used as a directory divider, regardless of the operating
+%system, so the result can be used, for example, in \cs{input} or
%\cs{includegraphics}.
%
%If an input file name is required (for example, with the
@@ -193,8 +200,16 @@
%using the shell escape, you'll need to be careful of this.
%\item[\shortarg{p} \meta{file} or \longarg{path} \meta{file}]
%Displays the canonical path of the given file or a blank line if
-%the file doesn't exists or the file permissions prohibit this
+%the file doesn't exist or the file permissions prohibit this
%action.
+%\item[\shortarg{e} \meta{file} or \longarg{dirname} \meta{file}]
+%(New to v1.1.)
+%Displays the canonical path of the given file's parent (that is, the
+%directory containing \meta{file}) or a blank line if
+%the file doesn't exist or the file permissions prohibit this
+%action. Note that this is different to the Unix-like
+%\texttt{dirname} command, which will return a relative path if
+%\meta{file} isn't an absolute path.
%\item[\shortarg{h} or \longarg{help}] Displays help message and
%exits.
%\item[\shortarg{v} or \longarg{version}] Displays version
@@ -203,7 +218,41 @@
%
%If multiple options are given, they will be processed in the
%order specified in the command line invocation. Each result will
-%be displayed on a separate line.
+%be displayed on a separate line. As from v1.1, if there are
+%multiple actions, each result will be grouped. This makes it easier
+%to process the results in \TeX. For example:
+%\begin{verbatim}
+%texosquery -l
+%\end{verbatim}
+%This just produces (for me):
+%\begin{verbatim}
+%en-GB.utf8
+%\end{verbatim}
+%whereas
+%\begin{verbatim}
+%texosquery -l -n
+%\end{verbatim}
+%produces:
+%\begin{verbatim}
+%{en-GB.utf8}
+%{D:20160714112732+01'00'}
+%\end{verbatim}
+%Note that unavailable information will produce an empty group.
+%For example (assuming \texttt{nofile} doesn't exist):
+%\begin{verbatim}
+%texosquery -l -d nofile -n
+%\end{verbatim}
+%produces:
+%\begin{verbatim}
+%{en-GB.utf8}
+%{}
+%{D:20160714112732+01'00'}
+%\end{verbatim}
+%whereas
+%\begin{verbatim}
+%texosquery -d nofile
+%\end{verbatim}
+%just displays an empty line.
%
%\section{texosquery.tex: generic \TeX\ code}
%You can run \texttt{texosquery} directly from \TeX's shell escape.
@@ -247,8 +296,8 @@
%(\texttt{texosquery.jar} will replace \verb|#| with \verb|\#| in places
%where it might possibly occur in the result, but in general it's
%best to avoid these characters in file names.)
-%There are some short cut commands for convenience, described below.
%
+%There are some short cut commands for convenience, described below.
%If any of these commands cause an error message in the form:
%\begin{verbatim}
%I can't find file `|texosquery'.
@@ -280,8 +329,27 @@
%TeXOSQuery:
%\end{verbatim}
%(the control sequence \meta{cs} will be set to empty).
-%This conditional will automatically be switched on if
-%\cs{shellescape} or \cs{pdfshellescape} is 0.
+%This conditional will automatically be switched on unless
+%\cs{shellescape} or \cs{pdfshellescape} is 1. (If
+%\texttt{texosquery.jar} is later allowed on the restricted list,
+%newer versions may change this default.)
+%
+%If multiple queries are required, it's more efficient to
+%perform them all in one go. For example:
+%\begin{verbatim}
+%\TeXOSQuery{\result}{-l -n -o}
+%
+%\def\parseresult#1#2#3{%
+% Locale: #1. Now: #2. OS: #3.%
+%}
+%
+%\ifx\result\empty
+% Query failed.
+%\else
+% \expandafter\parseresult\result
+%\fi
+%\end{verbatim}
+%(Make sure you have at least v1.1 for this to work correctly.)
%
%The locale (\shortarg{l} or \longarg{locale-lcs}) information can be
%obtained using:
@@ -346,7 +414,9 @@
%\end{flushleft}
%This is provided for the benefit of users who don't have
%\cs{pdfcreationdate} defined by their \TeX\ format (for example,
-%\XeTeX).
+%\XeTeX). As from v1.1, this ensures that the initial \texttt{D} has
+%category code 12 (which won't happen if \cs{TeXOSQuery} is used
+%explicitly).
%
%\begin{important}
%The remaining commands all require extra arguments after the
@@ -373,7 +443,9 @@
%\end{flushleft}
%where \meta{filename} is the name of the file.
%This is provided for the benefit of users who don't have
-%\cs{pdffilemoddate} defined by their \TeX\ format.
+%\cs{pdffilemoddate} defined by their \TeX\ format. As from v1.1,
+%this ensures that the initial \texttt{D} has category code 12 (which
+%won't happen if \cs{TeXOSQuery} is used explicitly).
%
%The size in bytes of a file
%(\shortarg{s} or \longarg{filesize}) can be obtained using:
@@ -436,6 +508,14 @@
%\end{flushleft}
%where \meta{filename} is the name of the file.
%
+%The canonical path of a file's parent
+%(\shortarg{e} or \longarg{dirname}) can be obtained using:
+%\DescribeMacro\TeXOSQueryDirName
+%\begin{flushleft}\ttfamily
+%\cs{TeXOSQueryDirName}\marg{cs}\marg{filename}
+%\end{flushleft}
+%where \meta{filename} is the name of the file.
+%
%\StopEventually{\phantomsection
%\addcontentsline{toc}{section}{Change History}%
%\PrintChanges
@@ -491,24 +571,26 @@
%
%\begin{macro}{\ifTeXOSQueryDryRun}
%Provide a dry-run mode.
+%\changes{1.1}{2016-07-14}{dry run mode only false by default if with
+%unrestricted mode}
% \begin{macrocode}
\newif\ifTeXOSQueryDryRun
-\TeXOSQueryDryRunfalse
+\TeXOSQueryDryRuntrue
% \end{macrocode}
%\end{macro}
%
-%If shell escape is disabled, automatically switch on dry-run mode.
+%If shell escape is unrestricted, automatically switch off dry-run mode.
% \begin{macrocode}
\ifx\shellescape\undefined
\ifx\pdfshellescape\undefined
\else
- \ifnum\pdfshellescape=0\relax
- \TeXOSQueryDryRuntrue
+ \ifnum\pdfshellescape=1\relax
+ \TeXOSQueryDryRunfalse
\fi
\fi
\else
- \ifnum\shellescape=0\relax
- \TeXOSQueryDryRuntrue
+ \ifnum\shellescape=1\relax
+ \TeXOSQueryDryRunfalse
\fi
\fi
% \end{macrocode}
@@ -608,9 +690,24 @@
%\end{macro}
%
%\begin{macro}{\TeXOSQueryNow}
+%\changes{1.1}{2016-07-14}{changed catcode of D to 12}
%Query the current time stamp.
% \begin{macrocode}
-\def\TeXOSQueryNow#1{\TeXOSQuery{#1}{\string-n}}
+\def\TeXOSQueryNow#1{%
+% \end{macrocode}
+% The \texttt{D} needs category code 12. (Don't need to worry about
+% \texttt{Z} as \texttt{texosquery.jar} uses \texttt{+00'00'} for
+% UTC+0.) This change can't be done with the other catcode changes
+% in \cs{TeXOSQuery}, as this is only appropriate for the PDF dates.
+% Save and restore the catcode rather than fiddle around with
+% scoping.
+% \begin{macrocode}
+ \edef\@texosquery@restore@D{%
+ \noexpand\catcode`\noexpand\D=\the\catcode`\D\relax}%
+ \catcode`\D=12\relax
+ \TeXOSQuery{#1}{\string-n}%
+ \@texosquery@restore@D
+}
% \end{macrocode}
%\end{macro}
%
@@ -632,10 +729,16 @@
%\end{macro}
%
%\begin{macro}{\TeXOSQueryFileDate}
+%\changes{1.1}{2016-07-14}{changed catcode of D to 12}
%Query the time stamp of the file given in the second argument.
% \begin{macrocode}
-\def\TeXOSQueryFileDate#1#2{\TeXOSQuery{#1}{\string-d
- \string'\texosquerystripquotes{#2}\string'}}
+\def\TeXOSQueryFileDate#1#2{%
+ \edef\@texosquery@restore@D{%
+ \noexpand\catcode`\noexpand\D=\the\catcode`\D\relax}%
+ \catcode`\D=12\relax
+ \TeXOSQuery{#1}{\string-d \string'\texosquerystripquotes{#2}\string'}%
+ \@texosquery@restore@D
+}
% \end{macrocode}
%\end{macro}
%
@@ -685,6 +788,16 @@
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\TeXOSQueryDirName}
+%\changes{1.1}{2016-07-14}{new}
+%Get the canonical path of the directory containing the file given
+%in the second argument.
+% \begin{macrocode}
+\def\TeXOSQueryDirName#1#2{\TeXOSQuery{#1}{\string-e
+ \string'\texosquerystripquotes{#2}\string'}}
+% \end{macrocode}
+%\end{macro}
+%
%All done.
%Restore the category code of \texttt{@}:
% \begin{macrocode}
@@ -708,7 +821,7 @@
%Identify package:
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{texosquery}[2016/07/08 v1.0 (NLCT)]
+\ProvidesPackage{texosquery}[2016/07/14 v1.1 (NLCT)]
% \end{macrocode}
%Load \texttt{texosquery.tex}:
% \begin{macrocode}
diff --git a/Master/texmf-dist/tex/latex/texosquery/texosquery.sty b/Master/texmf-dist/tex/latex/texosquery/texosquery.sty
index 7285f5acb36..70381419f66 100644
--- a/Master/texmf-dist/tex/latex/texosquery/texosquery.sty
+++ b/Master/texmf-dist/tex/latex/texosquery/texosquery.sty
@@ -41,7 +41,7 @@
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{texosquery}[2016/07/08 v1.0 (NLCT)]
+\ProvidesPackage{texosquery}[2016/07/14 v1.1 (NLCT)]
\input{texosquery}
\endinput
%%
diff --git a/Master/texmf-dist/tex/latex/texosquery/texosquery.tex b/Master/texmf-dist/tex/latex/texosquery/texosquery.tex
index b95300ac20d..285b6eb20c9 100644
--- a/Master/texmf-dist/tex/latex/texosquery/texosquery.tex
+++ b/Master/texmf-dist/tex/latex/texosquery/texosquery.tex
@@ -60,17 +60,17 @@
\def\TeXOSQueryInvoker#1{\@@input|"\TeXOSInvokerName\space#1" }
\fi
\newif\ifTeXOSQueryDryRun
-\TeXOSQueryDryRunfalse
+\TeXOSQueryDryRuntrue
\ifx\shellescape\undefined
\ifx\pdfshellescape\undefined
\else
- \ifnum\pdfshellescape=0\relax
- \TeXOSQueryDryRuntrue
+ \ifnum\pdfshellescape=1\relax
+ \TeXOSQueryDryRunfalse
\fi
\fi
\else
- \ifnum\shellescape=0\relax
- \TeXOSQueryDryRuntrue
+ \ifnum\shellescape=1\relax
+ \TeXOSQueryDryRunfalse
\fi
\fi
\def\TeXOSQuery#1#2{%
@@ -107,7 +107,13 @@
\def\TeXOSQueryVersion#1{\TeXOSQuery{#1}{\string-r}}
\def\TeXOSQueryArch#1{\TeXOSQuery{#1}{\string-a}}
\def\TeXOSQueryName#1{\TeXOSQuery{#1}{\string-o}}
-\def\TeXOSQueryNow#1{\TeXOSQuery{#1}{\string-n}}
+\def\TeXOSQueryNow#1{%
+ \edef\@texosquery@restore@D{%
+ \noexpand\catcode`\noexpand\D=\the\catcode`\D\relax}%
+ \catcode`\D=12\relax
+ \TeXOSQuery{#1}{\string-n}%
+ \@texosquery@restore@D
+}
\def\texosquerystripquotes#1{%
\@texosquery@stripquotes#1\@mid@texosquery@stripquotes
"\relax"\relax\@end@texosquery@stripquotes
@@ -118,8 +124,13 @@
\def\@@texosquery@stripquotes#1\@mid@texosquery@stripquotes#2\@end@texosquery@stripquotes{%
#1%
}
-\def\TeXOSQueryFileDate#1#2{\TeXOSQuery{#1}{\string-d
- \string'\texosquerystripquotes{#2}\string'}}
+\def\TeXOSQueryFileDate#1#2{%
+ \edef\@texosquery@restore@D{%
+ \noexpand\catcode`\noexpand\D=\the\catcode`\D\relax}%
+ \catcode`\D=12\relax
+ \TeXOSQuery{#1}{\string-d \string'\texosquerystripquotes{#2}\string'}%
+ \@texosquery@restore@D
+}
\def\TeXOSQueryFileSize#1#2{\TeXOSQuery{#1}{\string-s
\string'\texosquerystripquotes{#2}\string'}}
\def\TeXOSQueryFileList#1#2#3{\TeXOSQuery{#1}{%
@@ -132,6 +143,8 @@
\string'\texosquerystripquotes{#2}\string'}}
\def\TeXOSQueryFilePath#1#2{\TeXOSQuery{#1}{\string-p
\string'\texosquerystripquotes{#2}\string'}}
+\def\TeXOSQueryDirName#1#2{\TeXOSQuery{#1}{\string-e
+ \string'\texosquerystripquotes{#2}\string'}}
\@texosquery@restore@at
\endinput
%%