xref: /aoo4110/main/sd/res/webview/common.inc (revision b1cdbd2c)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22<%
23
24public const cnRefreshTime  = 5    ' refresh time in seconds
25
26' filename for file with all pictures and file containing the name of the current picture
27public const csFilePicture= "picture.txt"
28public const csFileCurrent= "currpic.txt"
29
30' constants for file-access
31const ForReading    =  1
32const ForWriting    =  2
33
34' new-line delimiter
35Dim FILE_LINE_DELIMITER
36FILE_LINE_DELIMITER = vbCRLF
37
38'/**
39' * Get data from file using a given separator.
40' */
41function File_getDataVirtual( sFilename, sServerPath, sSeperator )
42    call Err.Clear()
43
44    Dim aFSObject, sServerFileName
45
46    Set aFSObject = CreateObject("Scripting.FileSystemObject")
47    sServerFileName = aFSObject.BuildPath( Server.MapPath( sServerPath ), sFileName )
48
49    File_getDataVirtual = ""
50    if Err.Number = 0 then
51        File_getDataVirtual = File_read( sServerFileName )
52        If Not IsNull(File_getDataVirtual) Then
53            File_getDataVirtual = Replace( File_getDataVirtual, FILE_LINE_DELIMITER, sSeperator)
54            File_getDataVirtual = Split( File_getDataVirtual, sSeperator)
55        End If
56    end if
57end function
58
59'/**
60' * Get data from a file
61' */
62function File_read( sFilename )
63    call Err.Clear()
64
65    Dim aFSObject, aStream
66
67    Set aFSObject = CreateObject( "Scripting.FileSystemObject" )
68    Set aStream = aFSObject.OpenTextFile( sFilename, ForReading )
69
70    while not aStream.AtEndOfStream
71        File_read = File_read + aStream.ReadLine + FILE_LINE_DELIMITER
72    wend
73
74    aStream.Close
75end function
76
77'/**
78' * Get data from a file given by filename and virtual pathname
79' */
80Function File_readVirtual(sFileName, sServerPath)
81    call Err.Clear()
82
83    Dim aFSObject, sServerFileName
84
85    Set aFSObject = CreateObject("Scripting.FileSystemObject")
86    sServerFileName = aFSObject.BuildPath( Server.MapPath( sServerPath ), sFileName )
87
88    File_readVirtual = ""
89    if Err.Number = 0 then
90        File_readVirtual = File_read( sServerFileName )
91    end if
92End Function
93
94'/**
95' * Write data to a file
96' */
97function File_write( sFileName, sText )
98    call Err.Clear()
99
100    Dim aFSObject, aFile
101
102    Set aFSObject = CreateObject( "Scripting.FileSystemObject" )
103    if Err.Number = 0 then
104        Set aFile = aFSObject.CreateTextFile( sFileName, TRUE )
105        if Err.Number = 0 then
106            aFile.Write( sText )
107            aFile.Close
108        end if
109    end if
110
111    File_write = ( Err.Number = 0 )
112end function
113
114'/**
115' * Write data to a file given by filename and virtual pathname
116' */
117function File_writeVirtual( sFileName, sServerPath, sText )
118    call Err.Clear()
119
120    Dim aFSObject, aServerFile
121
122    Set aFSObject = CreateObject( "Scripting.FileSystemObject" )
123    aServerFile = aFSObject.BuildPath( Server.MapPath( sServerPath ), sFileName )
124
125    If Err.Number = 0 Then
126        File_writeVirtual = File_write( aServerFile, sText )
127    else
128        File_writeVirtual = false
129    End If
130end function
131%>