[svn:parrot] r44918 - trunk/src/pmc
petdance at svn.parrot.org
petdance at svn.parrot.org
Sun Mar 14 04:10:53 UTC 2010
Author: petdance
Date: Sun Mar 14 04:10:45 2010
New Revision: 44918
URL: https://trac.parrot.org/parrot/changeset/44918
Log:
consting
Modified:
trunk/src/pmc/file.pmc
Modified: trunk/src/pmc/file.pmc
==============================================================================
--- trunk/src/pmc/file.pmc Sun Mar 14 03:35:42 2010 (r44917)
+++ trunk/src/pmc/file.pmc Sun Mar 14 04:10:45 2010 (r44918)
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2008, Parrot Foundation.
+Copyright (C) 2001-2010, Parrot Foundation.
$Id$
=head1 NAME
@@ -65,9 +65,9 @@
struct stat info;
char * const cpath = Parrot_str_to_cstring(interp, path);
#ifdef WIN32
- int error = stat(cpath, &info);
+ const int error = stat(cpath, &info);
#else
- int error = lstat(cpath, &info);
+ const int error = lstat(cpath, &info);
#endif
Parrot_str_free_cstring(cpath);
@@ -91,14 +91,14 @@
struct stat info;
char * const cpath = Parrot_str_to_cstring(interp, path);
#ifdef WIN32
- int error = stat(cpath, &info);
+ const int error = stat(cpath, &info);
#else
- int error = lstat(cpath, &info);
+ const int error = lstat(cpath, &info);
#endif
Parrot_str_free_cstring(cpath);
if (error) {
- char *errmsg = strerror(errno);
+ const char * const errmsg = strerror(errno);
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_EXTERNAL_ERROR,
errmsg);
}
@@ -130,7 +130,7 @@
Parrot_str_free_cstring(cpath);
if (error) {
- char *errmsg = strerror(errno);
+ const char * const errmsg = strerror(errno);
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_EXTERNAL_ERROR,
errmsg);
}
@@ -159,12 +159,12 @@
struct stat info;
char * const cpath = Parrot_str_to_cstring(interp, path);
- int error = lstat(cpath, &info);
+ const int error = lstat(cpath, &info);
Parrot_str_free_cstring(cpath);
if (error) {
- char *errmsg = strerror(errno);
+ const char * const errmsg = strerror(errno);
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_EXTERNAL_ERROR,
errmsg);
}
@@ -196,24 +196,23 @@
#define CHUNK_SIZE 1024
char * const cfrom = Parrot_str_to_cstring(interp, from);
- FILE * source = fopen(cfrom, "rb");
+ FILE * const source = fopen(cfrom, "rb");
Parrot_str_free_cstring(cfrom);
if (source) {
- char * const cto = Parrot_str_to_cstring(interp, to);
- FILE * target = fopen(cto, "w+b");
+ char * const cto = Parrot_str_to_cstring(interp, to);
+ FILE * const target = fopen(cto, "w+b");
Parrot_str_free_cstring(cto);
if (target) {
- char buf[CHUNK_SIZE];
- size_t bytes_read, bytes_written;
-
while (!feof(source)) {
- bytes_read = fread(buf, 1, CHUNK_SIZE, source);
+ char buf[CHUNK_SIZE];
+ const size_t bytes_read = fread(buf, 1, CHUNK_SIZE, source);
+
if (bytes_read) {
- bytes_written = fwrite(buf, 1, bytes_read, target);
+ const size_t bytes_written = fwrite(buf, 1, bytes_read, target);
if (bytes_read != bytes_written) {
Parrot_ex_throw_from_c_args(interp, NULL,
EXCEPTION_EXTERNAL_ERROR, "Error writing file");
@@ -224,14 +223,14 @@
fclose(target);
}
else {
- char *errmsg = strerror(errno);
+ const char * const errmsg = strerror(errno);
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_EXTERNAL_ERROR,
errmsg);
}
fclose(source);
}
else {
- char *errmsg = strerror(errno);
+ const char * const errmsg = strerror(errno);
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_EXTERNAL_ERROR,
errmsg);
}
@@ -251,13 +250,13 @@
METHOD rename(STRING *from, STRING *to) {
char * const cfrom = Parrot_str_to_cstring(interp, from);
char * const cto = Parrot_str_to_cstring(interp, to);
- int error = rename(cfrom, cto);
+ const int error = rename(cfrom, cto);
Parrot_str_free_cstring(cfrom);
Parrot_str_free_cstring(cto);
if (error) {
- char *errmsg = strerror(errno);
+ const char * const errmsg = strerror(errno);
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_EXTERNAL_ERROR,
errmsg);
}
More information about the parrot-commits
mailing list