summaryrefslogtreecommitdiff
path: root/kaldi_io/src/tools/ATLAS/include/atlas_fopen.h
diff options
context:
space:
mode:
Diffstat (limited to 'kaldi_io/src/tools/ATLAS/include/atlas_fopen.h')
-rw-r--r--kaldi_io/src/tools/ATLAS/include/atlas_fopen.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/kaldi_io/src/tools/ATLAS/include/atlas_fopen.h b/kaldi_io/src/tools/ATLAS/include/atlas_fopen.h
new file mode 100644
index 0000000..aaed713
--- /dev/null
+++ b/kaldi_io/src/tools/ATLAS/include/atlas_fopen.h
@@ -0,0 +1,40 @@
+#ifndef ATLAS_FOPEN_H
+#define ATLAS_FOPEN_H
+
+static int FileExists(const char *path)
+{
+ FILE *fp;
+ int iret=0;
+ fp = fopen(path, "r");
+ if (fp)
+ {
+ fclose(fp);
+ iret = 1;
+ }
+ return(iret);
+}
+
+#ifdef ATL_FOPENDELAY
+static FILE *ATL_fopen(const char *path, const char *mode)
+/*
+ * Overload fopen so it waits for NFS propogation upon first read failure
+ */
+{
+ FILE *fp;
+ char ln[256];
+
+ fp = fopen(path, mode);
+ if (fp == NULL)
+ {
+ if (*mode == 'r') /* give NFS time to produce file */
+ {
+ sprintf(ln, "make waitfile waitfile=%s\n", path);
+ if (system(ln) == 0) fp = fopen(path, mode);
+ }
+ }
+ return(fp);
+}
+#define fopen ATL_fopen
+#endif
+
+#endif