+ else // Handle a bug in StdRegProv's EnumValues (http://groups.google.com/group/microsoft.public.win32.programmer.wmi/browse_thread/thread/d74c0ca865887e6b)
+ {
+ if ($this->GetStringValue($hKeyId, $subKey, '') != NULL)
+ $valueList[] = array('', self::REG_SZ);
+ else if ($this->GetDWORDValue($hKeyId, $subKey, '') != NULL)
+ $valueList[] = array('', self::REG_DWORD);
+ else if ($this->GetExpandedStringValue($hKeyId, $subKey, '') != NULL)
+ $valueList[] = array('', self::REG_EXPAND_SZ);
+ else if ($this->GetBinaryValue($hKeyId, $subKey, '') != NULL)
+ $valueList[] = array('', self::REG_BINARY);
+ else if ($this->GetMultiStringValue($hKeyId, $subKey, '') != NULL)
+ $valueList[] = array('', self::REG_MULTI_SZ);
+ }
+
+ return TRUE;
+ }
+
+ private function GetValueType($hKeyId, $subKey, $valueName)
+ {
+ $valueList = array();
+ if (!$this->EnumValues($hKeyId, $subKey, $valueList))
+ * Facility for reading and writing binary PropertyLists. Ported from {@link http://www.opensource.apple.com/source/CF/CF-476.15/CFBinaryPList.c CFBinaryPList.c}.
+ $val = gmmktime($hour,$min,$sec,$mon,$mday,$year) - CFDate::DATE_DIFF_APPLE_UNIX; // CFDate is a real, number of seconds since 01/01/2001 00:00:00 GMT
+
+ $bdata = self::typeBytes("3", 3); // 3 is 0011, type indicator for date
+ * Format constant for automatic format recognizing
+ * @var integer
+ */
+ const FORMAT_AUTO = 0;
+
+ /**
+ * Path of PropertyList
+ * @var string
+ */
+ protected $file = null;
+
+ /**
+ * Path of PropertyList
+ * @var integer
+ */
+ protected $format = null;
+
+ /**
+ * CFType nodes
+ * @var array
+ */
+ protected $value = array();
+
+ /**
+ * Position of iterator {@link http://php.net/manual/en/class.iterator.php}
+ * @var integer
+ */
+ protected $iteratorPosition = 0;
+
+ /**
+ * List of Keys for numerical iterator access {@link http://php.net/manual/en/class.iterator.php}
+ * @var array
+ */
+ protected $iteratorKeys = null;
+
+ /**
+ * List of NodeNames to ClassNames for resolving plist-files
+ * @var array
+ */
+ protected static $types = array(
+ 'string' => 'CFString',
+ 'real' => 'CFNumber',
+ 'integer' => 'CFNumber',
+ 'date' => 'CFDate',
+ 'true' => 'CFBoolean',
+ 'false' => 'CFBoolean',
+ 'data' => 'CFData',
+ 'array' => 'CFArray',
+ 'dict' => 'CFDictionary'
+ );
+
+
+ /**
+ * Create new CFPropertyList.
+ * If a path to a PropertyList is specified, it is loaded automatically.
+ * @param string $file Path of PropertyList
+ * @param integer $format he format of the property list, see {@link FORMAT_XML}, {@link FORMAT_BINARY} and {@link FORMAT_AUTO}, defaults to {@link FORMAT_AUTO}
+ * @throws IOException if file could not be read by {@link load()}
+ * @uses $file for storing the current file, if specified
+ * @uses load() for loading the plist-file
+ */
+ public function __construct($file=null,$format=self::FORMAT_AUTO) {
+ $this->file = $file;
+ $this->format = $format;
+ if($this->file) $this->load();
+ }
+
+ /**
+ * Load an XML PropertyList.
+ * @param string $file Path of PropertyList, defaults to {@link $file}
+ * @return void
+ * @throws IOException if file could not be read
+ * @throws DOMException if XML-file could not be read properly
+ * @uses load() to actually load the file
+ */
+ public function loadXML($file=null) {
+ $this->load($file,CFPropertyList::FORMAT_XML);
+ }
+
+ /**
+ * Load an binary PropertyList.
+ * @param string $file Path of PropertyList, defaults to {@link $file}
+ * @return void
+ * @throws IOException if file could not be read
+ * @throws PListException if binary plist-file could not be read properly
+ * @param string $file Path of PropertyList, defaults to {@link $file}
+ * @param integer $format The format of the property list, see {@link FORMAT_XML}, {@link FORMAT_BINARY} and {@link FORMAT_AUTO}, defaults to {@link $format}
+ * @return void
+ * @throws PListException if file format version is not 00
+ * @throws IOException if file could not be read
+ * @throws DOMException if plist file could not be parsed properly
+ * @uses $file if argument $file was not specified
+ * @param integer $format format the timestamp is specified in, use {@link TIMESTAMP_APPLE} or {@link TIMESTAMP_UNIX}, defaults to {@link TIMESTAMP_APPLE}
+ * @uses setValue() to convert the timestamp
+ */
+ function __construct($value,$format=CFDate::TIMESTAMP_UNIX) {
+ $this->setValue($value,$format);
+ }
+
+ /**
+ * Set the Date CFType's value.
+ * @param integer $value timestamp to set
+ * @param integer $format format the timestamp is specified in, use {@link TIMESTAMP_APPLE} or {@link TIMESTAMP_UNIX}, defaults to {@link TIMESTAMP_UNIX}
+ * @return void
+ * @uses TIMESTAMP_APPLE to determine timestamp type
+ * @uses TIMESTAMP_UNIX to determine timestamp type
+ * @uses DATE_DIFF_APPLE_UNIX to convert Apple-timestamp to Unix-timestamp
+ */
+ function setValue($value,$format=CFDate::TIMESTAMP_UNIX) {
+ * @param integer $format format the timestamp is specified in, use {@link TIMESTAMP_APPLE} or {@link TIMESTAMP_UNIX}, defaults to {@link TIMESTAMP_UNIX}
+ * @return integer Unix timestamp
+ * @uses TIMESTAMP_APPLE to determine timestamp type
+ * @uses TIMESTAMP_UNIX to determine timestamp type
+ * @uses DATE_DIFF_APPLE_UNIX to convert Unix-timestamp to Apple-timestamp
+ */
+ function getValue($format=CFDate::TIMESTAMP_UNIX) {
+// Flag that notes whether a simple (non-fatal) error has occurred
+$withError = false;
+
+// Minimum number of passed arguments is 3
+if($argc < 4)
+ exit("\nError! Invalid number of arguments! Correct format is Project_Name Torque_Root Project_Destination_Path (optional -O overwrite existing files)\n");
+// If there are 5 args and the last one isn't the override flag, it's a fatal error
+else if($argc == 5 && $argv[4] != "-O")
+ exit("\nInvalid argument of $argv[4]! Should be -O (optional overwrite existing files flag)\n");
+
+// Define our main working paths
+$torqueDir = $argv[2];
+$newPath = $argv[3] . "/".$argv[1] . "/";
+$templPath = $torqueDir . "/Templates/Full/";
+
+// Aesthetics...php doesn't care
+$newPath = str_replace("//", "/", $newPath);
+$templPath = str_replace("//", "/", $templPath);
+
+// Check if template path exists (ie user didn't do something wrong)
+if(is_dir($templPath))
+{
+ // If the destination path doesn't exist, make it
+ if(!is_dir($argv[3]))
+ mkdir($argv[3], 0777, true);
+
+ // If the project folder exists, check for -O
+ if(is_dir($newPath))
+ {
+ //If there's no -O, we exit out
+ if($argv[4] != "-O")
+ exit("\nProject folder already exists! Use -O as 4th argument is you wish to overwrite");
+
+ // Otherwise we delete the other .exe and .torsion as they won't otherwise be overwritten
+ echo("\nProject creation complete!\nYou can find your new project at $newPath.");
+// If there was, print ultra mega sad message
+else
+ echo("\nProject creation completed, however there were some errors. Please verify that your new project is correct.\nYou can find your new project at $newPath.");
+ $this->_trigger_fatal_error("'$obj_comp' is not a registered component of object '$object'", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);