]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the sqlite3OsFileModTime() interface. But it is still unused. The
authordrh <drh@noemail.net>
Tue, 15 Jun 2004 00:29:03 +0000 (00:29 +0000)
committerdrh <drh@noemail.net>
Tue, 15 Jun 2004 00:29:03 +0000 (00:29 +0000)
change counter in page 1 is always incremented. (CVS 1594)

FossilOrigin-Name: 186c6f93e12978907c5f0ff81d90bdf7367b9274

manifest
manifest.uuid
src/os.h
src/os_unix.c
src/os_win.c

index 7eccd53fea9647122210bb2ee2466293b0d8088f..b3e9a71e7d8fed0dc1e61784259cdd3c7a11b821 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\ssome\sold\stests\sto\suse\sthe\snew\sAPI.\s(CVS\s1593)
-D 2004-06-14T23:46:48
+C Add\sthe\ssqlite3OsFileModTime()\sinterface.\s\sBut\sit\sis\sstill\sunused.\s\sThe\nchange\scounter\sin\spage\s1\sis\salways\sincremented.\s(CVS\s1594)
+D 2004-06-15T00:29:04
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -40,13 +40,13 @@ F src/insert.c 68c7f3ddd6a7f1e5596d6996da1a2861b3789a3a
 F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
 F src/main.c a62c08c9d315c3ebc58bfb6b52ab5953ee8a3089
 F src/md5.c d77a389955759c8329bb357e3d71bac3d6eb710b
-F src/os.h 5df666d324f9c75bb21e0fab88e7028ee78149fb
+F src/os.h be7323afb3d371bcab438556ddb5fda397e3d815
 F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8
 F src/os_mac.c 129029f9faecf1133edcf72eaedd54c1c838b140
 F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4
-F src/os_unix.c 558006f887570435a8d546a1785b3798ee8cac01
+F src/os_unix.c 7eac2e840300848818f53e6e78cd19d128e936bd
 F src/os_unix.h 1cd6133cf66dea704b8646b70b2dfdcbdd9b3738
-F src/os_win.c 44b9291d5c10797fd0df932f22693406719c3958
+F src/os_win.c a60f9ebfb0ce3e5b2ce259f981af59a50b24fc8d
 F src/os_win.h 004eec47b1780fcaf07420ddc2072294b698d48c
 F src/pager.c d42af374b23b50805b42c08cbba5bd70dd73964f
 F src/pager.h bc58d32a9dee464f7268fb68652c130a4216e438
@@ -223,7 +223,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
 F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 4cfc5a36e9891a9b69209f94194fc492e203ab75
-R 78a27636c3b0e6afcf78533b6487d039
-U danielk1977
-Z 913380e0abc39a0407addfbc437c0f2c
+P af6edd2c0ad160435acd5bfa7af36c4f394f0bb8
+R 8390b0ef3815bc1230f728916c2a8366
+U drh
+Z b91d1156cec1d19e076cf36f8583344f
index e10236271ff8654351ffabcd90e453dc1923e1f0..48538b215af48162ce7503354491d94d45748805 100644 (file)
@@ -1 +1 @@
-af6edd2c0ad160435acd5bfa7af36c4f394f0bb8
\ No newline at end of file
+186c6f93e12978907c5f0ff81d90bdf7367b9274
\ No newline at end of file
index ea367be9456d4a0f2528e8a915999b284f106259..c7ae01ed7b860e7a632814965b3a45b2c4b2caad 100644 (file)
--- a/src/os.h
+++ b/src/os.h
@@ -160,6 +160,7 @@ int sqlite3OsFileSize(OsFile*, off_t *pSize);
 int sqlite3OsRandomSeed(char*);
 int sqlite3OsSleep(int ms);
 int sqlite3OsCurrentTime(double*);
+int sqlite3OsFileModTime(OsFile*, double*);
 void sqlite3OsEnterMutex(void);
 void sqlite3OsLeaveMutex(void);
 char *sqlite3OsFullPathname(const char*);
index 1a0541131456256a330a687d21c211de123ded9d..d605de78a34641d948bb4a1ab8b15dd3eac1a86b 100644 (file)
@@ -1042,4 +1042,22 @@ int sqlite3OsCurrentTime(double *prNow){
   return 0;
 }
 
+/*
+** Find the time that the file was last modified.  Write the
+** modification time and date as a Julian Day number into *prNow and
+** return SQLITE_OK.  Return SQLITE_ERROR if the modification
+** time cannot be found.
+*/
+int sqlite3OsFileModTime(OsFile *id, double *prNow){
+  int rc;
+  struct stat statbuf;
+  if( fstat(id->h, &statbuf)==0 ){
+    *prNow = statbuf.st_mtime/86400.0 + 2440587.5;
+    rc = SQLITE_OK;
+  }else{
+    rc = SQLITE_ERROR;
+  }
+  return rc;
+}
+
 #endif /* OS_UNIX */
index 394be52715a1b1155dae8fd721d754ea5e121da8..9ef8eb53d7b1fe2f8e5b7f138f91226c397201a5 100644 (file)
@@ -683,4 +683,27 @@ int sqlite3OsCurrentTime(double *prNow){
   return 0;
 }
 
+/*
+** Find the time that the file was last modified.  Write the
+** modification time and date as a Julian Day number into *prNow and
+** return SQLITE_OK.  Return SQLITE_ERROR if the modification
+** time cannot be found.
+*/
+int sqlite3OsFileModTime(OsFile *id, double *prMTime){
+  int rc;
+  FILETIME ft;
+  /* FILETIME structure is a 64-bit value representing the number of 
+  ** 100-nanosecond intervals since January 1, 1601 (= JD 2305813.5). 
+  */
+  if( GetFileTime(id->h, 0, 0, &ft) ){
+    double t;
+    t = ((double)ft.dwHighDateTime) * 4294967296.0; 
+    *prMTime = (t + ft.dwLowDateTime)/864000000000.0 + 2305813.5;
+    rc = SQLITE_OK;
+  }else{
+    rc = SQLITE_ERROR;
+  }
+  return rc;
+}
+
 #endif /* OS_WIN */