Index: qr_codes.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/qr_codes/Attic/qr_codes.admin.inc,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 qr_codes.admin.inc
--- qr_codes.admin.inc	11 Jul 2010 10:48:55 -0000	1.1.2.3
+++ qr_codes.admin.inc	26 Oct 2010 18:53:37 -0000
@@ -21,7 +21,17 @@ function qr_codes_settings() {
       '#default_value' => $engine,
     );
 
-    $count = count(file_scan_directory(file_directory_path() .'/qr_codes', '\.png$'));
+    $form['qr_codes_cache_dir'] = array(
+      '#type' => 'textfield',
+      '#title' => t('QR Codes Cache Directory'),
+      '#description' => t('QR Codes are saved locally once the image is created. Define where to save the image here.'),
+      '#default_value' => variable_get('qr_codes_cache_dir', 'qr_codes'),
+      '#element_validate' => array('_qr_codes_settings_cache_dir_validate'),
+      '#field_prefix' => file_directory_path() . '/',
+      '#required' => TRUE,
+    );
+
+    $count = count(file_scan_directory(file_directory_path() . '/' . variable_get('qr_codes_cache_dir', 'qr_codes'), '\.png$'));
     $form['qr_codes_clear_cache'] = array(
       '#type' => 'fieldset',
       '#title' => $count ? t('Cache: @count files cached', array('@count' => $count)) : t('Cache: There are no files in cache'),
@@ -77,7 +87,7 @@ function qr_codes_engine_settings($form_
  * Clear local files cache.
  */
 function qr_codes_clear_cache() {
-  $count = count(file_scan_directory(file_directory_path() .'/qr_codes', '\.png$', array('.', '..', 'CVS', '.svn'), 'file_delete'));
+  $count = count(file_scan_directory(file_directory_path() .'/' . variable_get('qr_codes_cache_dir', 'qr_codes'), '\.png$', array('.', '..', 'CVS', '.svn'), 'file_delete'));
   if ($count) {
     drupal_set_message(t('QR Codes local cache cleared. @count files have been deleted.', array('@count' => $count)));
   }
@@ -94,6 +104,24 @@ function _qr_codes_submit($form, $form_s
 }
 
 /**
+ * Implement an additional validation callback to the settings form for checking the cache directory exists.
+ */
+function _qr_codes_settings_cache_dir_validate($element, &$form_state) {
+  $valid = TRUE;
+  if (!empty($element['#value'])) {
+    if (preg_match('/[^a-zA-z0-9_-]/', $element['#value'])) {
+      $valid = FALSE;
+    }
+  } else {
+    $valid = FALSE;
+  }
+  if (!$valid) {
+    form_set_error($element['#name'], t('Invalid Cache Directory specified.  Directory must be set and can only contain letters, numbers, and \'-\' or \'_\'.'));
+  }
+
+}
+
+/**
  * Implement an additional validation callback to the settings form.
  */
 function _qr_codes_settings_validate($element, &$form_state) {
Index: qr_codes.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/qr_codes/qr_codes.module,v
retrieving revision 1.2.2.3
diff -u -p -r1.2.2.3 qr_codes.module
--- qr_codes.module	7 Jul 2010 22:40:10 -0000	1.2.2.3
+++ qr_codes.module	26 Oct 2010 18:53:38 -0000
@@ -68,7 +68,8 @@ function qr_codes_cron() {
   if (variable_get('qr_codes_cache_lifetime', 0)) {
     $now = time();
     $life = variable_get('qr_codes_cache_lifetime', 0) * 24 * 60 * 60;
-    foreach (file_scan_directory(file_directory_path() .'/qr_codes', '\.png$') as $file) {
+    $cache_dir = variable_get('qr_codes_cache_dir', 'qr_codes');
+    foreach (file_scan_directory(file_directory_path() . '/' . $cache_dir, '\.png$') as $file) {
       if ($now - filemtime($file->filename) > $life) {
         file_delete($file->filename);
       }
@@ -90,7 +91,7 @@ function qr_codes_cron() {
 function qr_codes_generate($data, $width, $height, $margin = 0) {
   // Create a unique file name using all image attributes.
   $imagename = md5($data . $width . $height . $margin) .'.png';
-  $dir = file_directory_path() . '/qr_codes/';
+  $dir = file_directory_path() . '/' . variable_get('qr_codes') . '/';
   $file = $dir . $imagename;
 
   // Cache locally.
