root/as2/Emzah/src/com/emzah/utils/RootPath.as

リビジョン 83, 4.0 kB (コミッタ: gen, コミット時期: 1 年 前)

HDDの名前を引くのでOSデフォルト値に変更

Line 
1 /*======================================================================*//**
2 * Config Class for ActionScript 2.0
3 *
4 * @author       Copyright (c) 2007 gen:emzah.com
5 * @version      0.1
6 *
7 * @link         http://emzah.com
8 * @link         http://blog.emzah.com
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
19 * either express or implied. See the License for the specific language
20 * governing permissions and limitations under the License.
21 *//*=======================================================================*/
22
23 /**
24  * RootPath.as はパスを統一するためのクラスです。
25  * @data 2007/06/08
26  * @usage
27  * <code>
28  * </code>
29  */
30
31 class com.emzah.utils.RootPath {
32    
33     //状態
34     private var buildStatus :  String;
35     //サーバー
36     private var locationServer :  String;
37     //URI HTML
38     public var htmlURI :  String;
39     //URI CGI
40     public var cgiURI :  String;
41     //URI local
42     public var localURI :  String;
43     //Domain
44     private var myDomain : String;
45     //Directory
46         public var Dir : String;
47     //OS
48     public var myOS : String;
49     //FlashPlayerVersion
50     public var fPV : Number;
51    
52     /**
53      * 共通
54      */
55
56     /**
57      * シェアオブジェクト
58      */
59     //シェアオブジェクトネーム
60     public var soName :  String;
61     //シェアオブジェクトパス
62     public var soPath :  String;
63    
64     //コンストラクタ
65     function RootPath(){
66        
67         var my_lc:LocalConnection = new LocalConnection();
68         myDomain = my_lc.domain();
69                
70         var fPVString:String = getVersion();
71        
72         this.fPV = Number(fPVString.substr(4,1));
73        
74         //状態設定
75         //this.buildStatus = "";
76        // this.buildStatus = "alpha/";
77         //this.buildStatus = "beta1/";
78         //this.buildStatus= "RC1/" 
79                
80                 var place:String;
81                 var Im:String;
82                
83                 //Publish File Path
84                 /*
85                  * If Mac
86                  * var path:String = "Users/{ USER }/Documents/emzah/src/html/http/";
87                  *
88                  * If Win
89                  * var path:String = "D://emzah/src/html/http/";
90                  *
91                  */
92                 var path:String = "";
93                
94                 if(my_lc.domain() == "localhost"){
95                         place = "local" ;
96                         if(CheckOS("Mac")){
97                                
98                                         if(System.capabilities.playerType == "StandAlone" ||System.capabilities.playerType == "External"){
99                                                
100                                                 Dir=":";
101                                                 //root HDD name
102                                                 htmlURI = "Macintosh HD:" + setPath(path);
103                                                
104                                         }else{
105                                                
106                                                 Dir="/";
107                                                 htmlURI = "file://localhost/" +  setPath(path);
108
109                                         }
110                                        
111                                  Im = "Mac";
112                                
113             }else if(CheckOS("Win")){
114        
115                                         if(System.capabilities.playerType == "StandAlone" ||System.capabilities.playerType == "External"){
116
117                                                 Dir= "/";
118                                                 htmlURI =  setPath(path) ;
119
120                                         }else{
121                                                
122                                                 Dir= "/";
123                                                 htmlURI = "file:///" + setPath(path);
124                                                
125                                         }
126                                
127                                 Im = "Win";
128                     }
129         }else{
130                        
131                         Dir="/";
132                         htmlURI = myDomain;
133                        
134                         place= "WEB";
135                         Im = "";
136        
137         }
138
139     }
140    
141     public function CheckOS(_os:String):Boolean{
142                 /**
143                  * Mac or Win Check
144                  *  "Windows XP", "Windows 2000", "Windows NT", "Windows 98/ME", "Windows 95", "Windows CE" (available only in Flash Player SDK,
145                  *  not in the desktop version),
146                  *   "Linux", and "MacOS". The server string is OS.
147                  */
148                 myOS = System.capabilities.os;
149                  
150                 if(_os == myOS.substr(0,3)){
151                         return true;
152                 }else{
153                         return false;
154                 }
155         }
156        
157         public function setPath(_path:String):String{
158
159                 var pathStr:Array = _path.split("/");
160
161                 var dirPath:String = "";
162
163                 for(var i = 0 ;i < pathStr.length;i++){
164                         if(pathStr[i] != ""){
165                                 dirPath +=  pathStr[i] + Dir;
166                         }
167                 }
168                 return dirPath;
169                
170         }
171    
172 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。