80 return SIZE_MAX;
81 }
82 return value;
83 }
84
85 static bool file_exists(const char* filename) {
86 struct stat dummy_stat;
87 return os::stat(filename, &dummy_stat) == 0;
88 }
89
90 static uint number_of_digits(uint number) {
91 return number < 10 ? 1 : (number < 100 ? 2 : 3);
92 }
93
94 static bool is_regular_file(const char* filename) {
95 struct stat st;
96 int ret = os::stat(filename, &st);
97 if (ret != 0) {
98 return false;
99 }
100 #ifdef _WINDOWS
101 return (st.st_mode & S_IFMT) == _S_IFREG;
102 #else
103 return S_ISREG(st.st_mode);
104 #endif
105 }
106
107 // Try to find the next number that should be used for file rotation.
108 // Return UINT_MAX on error.
109 static uint next_file_number(const char* filename,
110 uint number_of_digits,
111 uint filecount,
112 outputStream* errstream) {
113 bool found = false;
114 uint next_num = 0;
115
116 // len is filename + dot + digits + null char
117 size_t len = strlen(filename) + number_of_digits + 2;
118 char* archive_name = NEW_C_HEAP_ARRAY(char, len, mtLogging);
119 char* oldest_name = NEW_C_HEAP_ARRAY(char, len, mtLogging);
120
121 for (uint i = 0; i < filecount; i++) {
122 int ret = jio_snprintf(archive_name, len, "%s.%0*u",
123 filename, number_of_digits, i);
124 assert(ret > 0 && static_cast<size_t>(ret) == len - 1,
|
80 return SIZE_MAX;
81 }
82 return value;
83 }
84
85 static bool file_exists(const char* filename) {
86 struct stat dummy_stat;
87 return os::stat(filename, &dummy_stat) == 0;
88 }
89
90 static uint number_of_digits(uint number) {
91 return number < 10 ? 1 : (number < 100 ? 2 : 3);
92 }
93
94 static bool is_regular_file(const char* filename) {
95 struct stat st;
96 int ret = os::stat(filename, &st);
97 if (ret != 0) {
98 return false;
99 }
100 return (st.st_mode & S_IFMT) == S_IFREG;
101 }
102
103 // Try to find the next number that should be used for file rotation.
104 // Return UINT_MAX on error.
105 static uint next_file_number(const char* filename,
106 uint number_of_digits,
107 uint filecount,
108 outputStream* errstream) {
109 bool found = false;
110 uint next_num = 0;
111
112 // len is filename + dot + digits + null char
113 size_t len = strlen(filename) + number_of_digits + 2;
114 char* archive_name = NEW_C_HEAP_ARRAY(char, len, mtLogging);
115 char* oldest_name = NEW_C_HEAP_ARRAY(char, len, mtLogging);
116
117 for (uint i = 0; i < filecount; i++) {
118 int ret = jio_snprintf(archive_name, len, "%s.%0*u",
119 filename, number_of_digits, i);
120 assert(ret > 0 && static_cast<size_t>(ret) == len - 1,
|