Make WordPress Core

Opened 14 years ago

Closed 9 years ago

#21403 closed enhancement (maybelater)

Introduce wp_scandir, remove opendir / closedir code

Reported by: wonderboymusic Owned by:
Priority: normal Milestone:
Component: Filesystem API Version: 3.0
Severity: normal Keywords: needs-refresh dev-feedback
Cc: Focuses:

Description

There is @opendir code all over the place that is not standardized. On top of that, there is plenty of code that is duplicated and could be condensed into one handy function. Plus, in all of the places we are using opendir(), we really want to be using scandir().

I have created a master function in load.php called wp_scandir() that does the basics:

  • scans a directory for files / subdirectories
  • filters list by extension(s)
  • optionally returns ONLY files

This cleans up code in many places.

Attachments (1)

wp-scandir.diff​ (16.4 KB ) - added by wonderboymusic 14 years ago.

Download all attachments as: .zip

Change History (7)

#1 @scribu
14 years ago

Wouldn't ​glob() be more appropriate?

#2 @markoheijnen
14 years ago

I'm curious how this effect the performance

#3 @wonderboymusic
14 years ago

opendir is the PHP4 alternative to scandir - scandir is faster and requires less code. glob might be ok but is less standard. I was following @nacin's lead, he used scandir in WP_Theme

#4 @Mamaduka
14 years ago

  • Cc georgemamadashvili@… added

#5 @chriscct7
12 years ago

  • Keywords needs-refresh dev-feedback added; has-patch removed

#6 @wonderboymusic
9 years ago

  • Milestone Awaiting Review
  • Resolution → maybelater
  • Status new → closed
Note: See TracTickets for help on using tickets.