RE: [PHP-DEV] disktotalspace()

2001-05-15 Thread James Moore



 Well, there is no CVS standard, but rather a standard in the
 CODING_GUIDELINES file.  However, in this case, I think you can
 disregard that, since the function is so similiar (in nature) to the
 diskfreespace() function that disktotalspace() makes the most sense,
 instead of disk_totalspace() or disk_total_space().

Wouldnt it make more sense here to correct the name of diskfree_space and
and an alias back rather than introducing new functions that are named not
according the the standard?

- James


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] disktotalspace()

2001-05-15 Thread Zeev Suraski

At 01:25 16/5/2001, Jon Parise wrote:
  Wouldnt it make more sense here to correct the name of diskfree_space and
  and an alias back rather than introducing new functions that are named not
  according the the standard?

No, I don't think it's really that much of an issue.

We've had a huge thread about this, we did decide to try and stick with the 
standard...

Zeev


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] disktotalspace()

2001-05-15 Thread Jon Parise

On Wed, May 16, 2001 at 01:37:51AM +0300, Zeev Suraski wrote:

 Yes, but this new version will work correctly under Unix-like
 systems and Windows NT / 2000 systems.  Executing system binaries
 is sloppy for things like this, anyway.
 
 Or perhaps I'm missing your point?
 
 I think  you were missing the point :)  I meant that I think there's no 
 need to load kernel32.dll and all that, we can simply call 
 GetDiskFreeSpaceEx() directly.

Okay, my lexer wasn't in the correct context when I read your
reply.  I follow you now.

I assume you're suggesting an update of both the existing
diskfreespace() and the proposed disktotalspace() functions,
correct?
 
 BTW, in light of the standard naming convention initiative, 
 disktotalspace() is probably a bad name and should be more like 
 disk_total_space()...

How do you feel about renaming the existing diskfreespace()
function to disk_free_space() (with an alias for backwards
compatibility)?

-- 
Jon Parise ([EMAIL PROTECTED])  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] disktotalspace()

2001-05-15 Thread Zeev Suraski

At 01:40 16/5/2001, Jon Parise wrote:
How do you feel about renaming the existing diskfreespace()
function to disk_free_space() (with an alias for backwards
compatibility)?

A warm fuzzy feeling :)  Seriously though, it's been discussed in great 
length, and at least from what I understood, going in that direction was 
the general idea.  Slowly, but surely :)

Zeev


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] disktotalspace()

2001-05-15 Thread Jon Parise

On Wed, May 16, 2001 at 01:47:15AM +0300, Zeev Suraski wrote:

 How do you feel about renaming the existing diskfreespace()
 function to disk_free_space() (with an alias for backwards
 compatibility)?
 
 A warm fuzzy feeling :)  Seriously though, it's been discussed in great 
 length, and at least from what I understood, going in that direction was 
 the general idea.  Slowly, but surely :)
 
Alright, I'm now caught up with all of the messages related to
this.  I'll go through and start sorting out all of the changes
that have been discussed over the rest of the evening.  I'll try
and keep all of the changes separate.

-- 
Jon Parise ([EMAIL PROTECTED])  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] disktotalspace()

2001-05-15 Thread Jon Parise

On Tue, May 15, 2001 at 07:14:27AM -0400, Sterling Hughes wrote:

  How do you feel about renaming the existing diskfreespace()
  function to disk_free_space() (with an alias for backwards
  compatibility)?
 
  A warm fuzzy feeling :)  Seriously though, it's been discussed in 
  great  length, and at least from what I understood, going in that 
  direction was  the general idea.  Slowly, but surely :)
 
 Actually, at least what I remember from the conversations, this was 
 being put off till someone actually did some work at renaming a set of 
 the functions, and there are still a good number of unresolved issues 
 regarding function naming (str_tok() or strtok() to name one).  At this 
 point, I think placing it in there as disktotalspace() and leaving 
 diskfreespace() alone would be the right thing to do.  Then when all the 
 naming issues are hashed out/someone has some work to show, change both 
 of the functions to their proper names.  At this point a 
 disk_free_space() function seems out of place in the current naming 
 scheme (I wouldn't object as much to disk_freespace() and 
 disk_totalspace(), but overall, I think we should wait until the rest of 
 the source is namespace complaint and we've decided how to handle the 
 change to the new naming conventions.)
 
Ugh.  I wish I had read this a few minutes earlier.  I just made 
the name change based on what I assumed was consensus.

If someone feels the need to revert the change, go ahead.  I 
prefer to just leave it now that I've already changed it, and 
then I'll add the new function as disk_total_space().

-- 
Jon Parise ([EMAIL PROTECTED])  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DEV] disktotalspace()

2001-05-15 Thread James Moore

   How do you feel about renaming the existing diskfreespace()
   function to disk_free_space() (with an alias for backwards
   compatibility)?
  
   A warm fuzzy feeling :)  Seriously though, it's been discussed in
   great  length, and at least from what I understood, going in that
   direction was  the general idea.  Slowly, but surely :)
  
  Actually, at least what I remember from the conversations, this was
  being put off till someone actually did some work at renaming a set of
  the functions, and there are still a good number of unresolved issues
  regarding function naming (str_tok() or strtok() to name one).  At this
  point, I think placing it in there as disktotalspace() and leaving
  diskfreespace() alone would be the right thing to do.  Then
 when all the
  naming issues are hashed out/someone has some work to show, change both
  of the functions to their proper names.  At this point a
  disk_free_space() function seems out of place in the current naming
  scheme (I wouldn't object as much to disk_freespace() and
  disk_totalspace(), but overall, I think we should wait until
 the rest of
  the source is namespace complaint and we've decided how to handle the
  change to the new naming conventions.)

 Ugh.  I wish I had read this a few minutes earlier.  I just made
 the name change based on what I assumed was consensus.

 If someone feels the need to revert the change, go ahead.  I
 prefer to just leave it now that I've already changed it, and
 then I'll add the new function as disk_total_space().

Why add more functions to be depreciated soon?? Lets name new functions
properly, bring others into line as and when and as needed add alaises until
we fix it.

- James


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] disktotalspace()

2001-05-15 Thread Jon Parise

On Wed, May 16, 2001 at 01:01:46AM +0100, James Moore wrote:

  If someone feels the need to revert the change, go ahead.  I
  prefer to just leave it now that I've already changed it, and
  then I'll add the new function as disk_total_space().
 
 Why add more functions to be depreciated soon?? Lets name new functions
 properly, bring others into line as and when and as needed add alaises until
 we fix it.
 
I agree.  I thought that disk_total_space() would be the proper
name for this new function.

-- 
Jon Parise ([EMAIL PROTECTED])  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] disktotalspace()

2001-05-15 Thread Sterling Hughes

James Moore wrote:

How do you feel about renaming the existing diskfreespace()
function to disk_free_space() (with an alias for backwards
compatibility)?

A warm fuzzy feeling :)  Seriously though, it's been discussed in
great  length, and at least from what I understood, going in that
direction was  the general idea.  Slowly, but surely :)


Actually, at least what I remember from the conversations, this was
being put off till someone actually did some work at renaming a set of
the functions, and there are still a good number of unresolved issues
regarding function naming (str_tok() or strtok() to name one).  At this
point, I think placing it in there as disktotalspace() and leaving
diskfreespace() alone would be the right thing to do.  Then

when all the

naming issues are hashed out/someone has some work to show, change both
of the functions to their proper names.  At this point a
disk_free_space() function seems out of place in the current naming
scheme (I wouldn't object as much to disk_freespace() and
disk_totalspace(), but overall, I think we should wait until

the rest of

the source is namespace complaint and we've decided how to handle the
change to the new naming conventions.)

Ugh.  I wish I had read this a few minutes earlier.  I just made
the name change based on what I assumed was consensus.

If someone feels the need to revert the change, go ahead.  I
prefer to just leave it now that I've already changed it, and
then I'll add the new function as disk_total_space().

 
 Why add more functions to be depreciated soon?? Lets name new functions
 properly, bring others into line as and when and as needed add alaises until
 we fix it.
 


Well, for one thing, no one has agreed on a naming convention yet.

So its possible that now we'll have two aliases:

diskfreespace
disk_free_space

and then the actual function name:

disk_freespace()
or
disk_space_free()

Furthermore, it was never agreed that the core functions should follow 
any naming conventions.  In fact, I think that would be plain stupid. 
The extensions should follow a naming convention, however, the core 
functions need not follow any such convention.  This is how it is with 
almost every other language (Perl and C for example).

-Sterling


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] disktotalspace()

2001-05-15 Thread Jon Parise

On Tue, May 15, 2001 at 08:50:48AM -0400, Sterling Hughes wrote:

 Well, for one thing, no one has agreed on a naming convention yet.
 
 So its possible that now we'll have two aliases:
 
 diskfreespace
 disk_free_space
 
 and then the actual function name:
 
 disk_freespace()
 or
 disk_space_free()
 
 Furthermore, it was never agreed that the core functions should follow 
 any naming conventions.  In fact, I think that would be plain stupid. 
 The extensions should follow a naming convention, however, the core 
 functions need not follow any such convention.  This is how it is with 
 almost every other language (Perl and C for example).

Okay.  Well, I'm now wiping my hands of the issue.  I'll leave it
up to the rest of you folks to establish the naming conventions
and make the associated changes in the source and documentation.

Would you like me to change the two functions to the existing
naming scheme (no hyphens) until something new is decided?

My changes have only affected the HEAD branch so far, so we don't
need to worry about aliasing anything until that code makes it
into a release.

-- 
Jon Parise ([EMAIL PROTECTED])  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] disktotalspace()

2001-05-14 Thread Sterling Hughes


The patch looks ok, a couple of questions though...

1) disktotalspace() looks like a memory intensive operation, perhaps 
having a cache might not be a bad idea.

2) I see you use LoadLibrary to load in kernel32.dll on Win32, what 
happens on that system when I call disk total space more than once? 
Could this cause a crash??  Also, perhaps you don't need to load the 
library in more than once, does anyone know of any other areas where 
this library is loaded in?

3)  Why not just have a statfs() function instead, that would return all 
this info and more?

 Does anyone object to my adding a new function disktotalspace()?
 
 A friend of mine ran into a situation where he required an
 OS-independent means of determining the amount of free space on a
 filesystem (meaning executing and parsing 'df -k' wasn't going to
 cut it).
 
 PHP already has diskfreespace(), so I see no reason why it can't
 also have disktotalspace().
 
 His patch is attached.  If no one objects, I'll commit this in a
 day or two (along with documentation, which I have yet to write).
 
 
 
 
 
 ? php_cvs_disktotal_patch.diff
 ? disktotalspace.diff
 Index: basic_functions.c
 ===
 RCS file: /repository/php4/ext/standard/basic_functions.c,v
 retrieving revision 1.337
 diff -u -r1.337 basic_functions.c
 --- basic_functions.c 2001/05/14 20:56:05 1.337
 +++ basic_functions.c 2001/05/15 02:51:28
 @@ -505,6 +505,7 @@
   PHP_FE(chmod,   NULL)
   PHP_FE(touch,   NULL)
   PHP_FE(clearstatcache,  NULL)
 + PHP_FE(disktotalspace,  NULL)
   PHP_FE(diskfreespace,   NULL)
  
   /* functions from mail.c */
 Index: filestat.c
 ===
 RCS file: /repository/php4/ext/standard/filestat.c,v
 retrieving revision 1.65
 diff -u -r1.65 filestat.c
 --- filestat.c2001/05/14 18:30:07 1.65
 +++ filestat.c2001/05/15 02:51:28
 @@ -124,6 +124,107 @@
   return SUCCESS;
  }
  
 +/* {{{ proto double disktotalspace(string path)
 +   Get total diskspace for filesystem that path is on */
 +PHP_FUNCTION(disktotalspace)
 +{
 + pval **path;
 +#ifdef WINDOWS
 + double bytestotal;
 +
 + HINSTANCE kernel32;
 + FARPROC gdfse;
 + typedef BOOL (WINAPI *gdfse_func)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, 
PULARGE_INTEGER);
 + gdfse_func func;
 +
 + /* These are used by GetDiskFreeSpaceEx, if available. */
 + ULARGE_INTEGER FreeBytesAvailableToCaller;
 + ULARGE_INTEGER TotalNumberOfBytes;
 + ULARGE_INTEGER TotalNumberOfFreeBytes;
 +
 + /* These are used by GetDiskFreeSpace otherwise. */
 + DWORD SectorsPerCluster;
 + DWORD BytesPerSector;
 + DWORD NumberOfFreeClusters;
 + DWORD TotalNumberOfClusters;
 +
 +#else /* not - WINDOWS */
 +#if defined(HAVE_SYS_STATVFS_H)  defined(HAVE_STATVFS)
 + struct statvfs buf;
 +#elif defined(HAVE_SYS_STATFS_H)  defined(HAVE_STATFS)
 + struct statfs buf;
 +#endif
 + double bytestotal = 0;
 +#endif /* WINDOWS */
 +
 + if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1,path)==FAILURE) {
 + WRONG_PARAM_COUNT;
 + }
 +
 + convert_to_string_ex(path);
 +
 + if (php_check_open_basedir((*path)-value.str.val)) RETURN_FALSE;
 +
 +#ifdef WINDOWS
 + /* GetDiskFreeSpaceEx is only available in NT and Win95 post-OSR2,
 +so we have to jump through some hoops to see if the function
 +exists. */
 + kernel32 = LoadLibrary(kernel32.dll);
 + if (kernel32) {
 + gdfse = GetProcAddress(kernel32, GetDiskFreeSpaceExA);
 + /* It's available, so we can call it. */
 + if (gdfse) {
 + func = (gdfse_func)gdfse;
 + if (func((*path)-value.str.val,
 + FreeBytesAvailableToCaller,
 + TotalNumberOfBytes,
 + TotalNumberOfFreeBytes) == 0) RETURN_FALSE;
 +
 + /* i know - this is ugly, but i works ([EMAIL PROTECTED]) */
 + bytestotal  = TotalNumberOfBytes.HighPart *
 + (double) (((unsigned long)1)  31) * 2.0 +
 + TotalNumberOfBytes.LowPart;
 + }
 + /* If it's not available, we just use GetDiskFreeSpace */
 + else {
 + if (GetDiskFreeSpace((*path)-value.str.val,
 + SectorsPerCluster, BytesPerSector,
 + NumberOfFreeClusters, TotalNumberOfClusters) == 0) 
RETURN_FALSE;
 + bytestotal = (double)TotalNumberOfClusters * 
(double)SectorsPerCluster * (double)BytesPerSector;
 + }
 + }
 + else {
 + 

Re: [PHP-DEV] disktotalspace()

2001-05-14 Thread Jon Parise

On Mon, May 14, 2001 at 11:51:52PM -0400, Sterling Hughes wrote:

 The patch looks ok, a couple of questions though...

I'm not the original author of the function, but so I'll answer
as best I can.
 
 1) disktotalspace() looks like a memory intensive operation, perhaps 
 having a cache might not be a bad idea.

Perhaps.  I haven't profiled the function's use, but I can think
of possible situations where it may be called multiple times in a
script's execution.
 
 2) I see you use LoadLibrary to load in kernel32.dll on Win32, what 
 happens on that system when I call disk total space more than once? 
 Could this cause a crash??  Also, perhaps you don't need to load the 
 library in more than once, does anyone know of any other areas where 
 this library is loaded in?

I know very little about Windows program, although I understand
the points you raise.  All I can say is that the Windows-specific
portions of the disktotalspace() function were adapted from the
preexisting diskfreespace() function.  The original author of
that code would be the best person to ask, I think.
 
 3)  Why not just have a statfs() function instead, that would return all 
 this info and more?
 
Again, the new function is based on diskfreespace(), so I think
we just assumed the was a reason it was done that way.  I presume
that compatibility was the primary concern, but I can't say for
sure.

-- 
Jon Parise ([EMAIL PROTECTED])  .  Rochester Inst. of Technology
http://www.csh.rit.edu/~jon/  :  Computer Science House Member

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]