[xiph-cvs] cvs commit: ices/src util.c util.h
Brendan
brendan at xiph.org
Sun Mar 16 00:22:39 PST 2003
brendan 03/03/16 03:22:39
Modified: src util.c util.h
Log:
More dead code removal (pending next commit)
Sanity check in "ices_util_percent"
Never return null from "ices_util_file_time"
This file is very corny.
Revision Changes Path
1.16 +9 -25 ices/src/util.c
Index: util.c
===================================================================
RCS file: /cvs/ice/ices/src/util.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- util.c 14 Mar 2003 22:42:25 -0000 1.15
+++ util.c 16 Mar 2003 08:22:39 -0000 1.16
@@ -204,20 +204,6 @@
return 0;
}
-/* Return the size of the file pointed to by fd */
-int
-ices_util_fd_size (int fd)
-{
- struct stat st;
-
- if (fstat (fd, &st) == -1) {
- ices_log_error ("ERROR: Could not stat file");
- return -1;
- }
-
- return st.st_size;
-}
-
/* Make sure directory exists and is a directory */
int
ices_util_directory_exists (const char *name)
@@ -258,9 +244,12 @@
/* Wrapper function for percentage */
double
-ices_util_percent (int this, int of_that)
+ices_util_percent (int num, int den)
{
- return (double)((double)this / (double) of_that) * 100.0;
+ if (! den)
+ return 0;
+
+ return (double)((double)num / (double)den) * 100.0;
}
/* Given bitrate and filesize, report the length of the given file
@@ -272,8 +261,10 @@
unsigned long int days, hours, minutes, nseconds, remains;
unsigned long int seconds;
- if (!bitrate)
- return NULL;
+ if (!bitrate) {
+ sprintf (buf, "0:0:0:0");
+ return buf;
+ }
/* << 7 == 1024 (bits->kbits) / 8 (bits->bytes) */
seconds = filesize / ((bitrate * 1000) >> 3);
@@ -309,13 +300,6 @@
{
if (ptr)
free (ptr);
-}
-
-/* Wrapper function around close */
-void
-ices_util_close (int fd)
-{
- close (fd);
}
/* Verify that file exists, and is readable */
<p><p>1.7 +0 -2 ices/src/util.h
Index: util.h
===================================================================
RCS file: /cvs/ice/ices/src/util.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- util.h 15 Mar 2003 18:37:53 -0000 1.6
+++ util.h 16 Mar 2003 08:22:39 -0000 1.7
@@ -32,7 +32,6 @@
char *ices_util_get_random_filename (char *namespace, char *type);
int ices_util_remove (const char *filename);
int ices_util_get_random (void);
-int ices_util_fd_size (int fd);
int ices_util_is_regular_file (int fd);
int ices_util_directory_create (const char *filename);
int ices_util_directory_exists (const char *filename);
@@ -42,5 +41,4 @@
char *namespace);
const char *ices_util_strerror (int error, char *namespace, int maxsize);
void ices_util_free (void *ptr);
-void ices_util_close (int fd);
int ices_util_verify_file (const char *filename);
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list