Changeset 204 for branches/samba-3.2.x/source/lib/time.c
- Timestamp:
- May 20, 2009, 6:46:53 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/lib/time.c
r138 r204 827 827 ****************************************************************************/ 828 828 829 time_t get_create_time(const SMB_STRUCT_STAT *st,bool fake_dirs)829 static time_t calc_create_time(const SMB_STRUCT_STAT *st) 830 830 { 831 831 time_t ret, ret1; 832 832 833 if(S_ISDIR(st->st_mode) && fake_dirs) {834 return (time_t)315493200L; /* 1/1/1980 */835 }836 837 833 ret = MIN(st->st_ctime, st->st_mtime); 838 834 ret1 = MIN(ret, st->st_atime); … … 849 845 } 850 846 851 struct timespec get_create_timespec(const SMB_STRUCT_STAT *st,bool fake_dirs) 852 { 853 struct timespec ts; 854 ts.tv_sec = get_create_time(st, fake_dirs); 855 ts.tv_nsec = 0; 856 return ts; 847 /**************************************************************************** 848 Return the 'create time' from a stat struct if it exists (birthtime) or else 849 use the best approximation. 850 ****************************************************************************/ 851 852 struct timespec get_create_timespec(const SMB_STRUCT_STAT *pst,bool fake_dirs) 853 { 854 struct timespec ret; 855 856 if(S_ISDIR(pst->st_mode) && fake_dirs) { 857 ret.tv_sec = 315493200L; /* 1/1/1980 */ 858 ret.tv_nsec = 0; 859 return ret; 860 } 861 862 #if defined(HAVE_STAT_ST_BIRTHTIMESPEC) 863 ret = pst->st_birthtimespec; 864 #elif defined(HAVE_STAT_ST_BIRTHTIMENSEC) 865 ret.tv_sec = pst->st_birthtime; 866 ret.tv_nsec = pst->st_birthtimenspec; 867 #elif defined(HAVE_STAT_ST_BIRTHTIME) 868 ret.tv_sec = pst->st_birthtime; 869 ret.tv_nsec = 0; 870 #else 871 ret.tv_sec = calc_create_time(pst); 872 ret.tv_nsec = 0; 873 #endif 874 875 /* Deal with systems that don't initialize birthtime correctly. 876 * Pointed out by SATOH Fumiyasu <fumiyas@osstech.jp>. 877 */ 878 if (null_timespec(ret)) { 879 ret.tv_sec = calc_create_time(pst); 880 ret.tv_nsec = 0; 881 } 882 return ret; 857 883 } 858 884
Note:
See TracChangeset
for help on using the changeset viewer.