Last change
on this file since 4 was
4,
checked in by zhangj, 10 years ago
|
Initial import--MML version from SOLEIL@2013
|
File size:
688 bytes
|
Line | |
---|
1 | function fid = openfile(filename,permission) |
---|
2 | %OPENFILE Open a file in read/write mode, catching errors |
---|
3 | % FID = OPENFILE(FILENAME,PERMISSION) opens file FILENAME |
---|
4 | % in PERMISSION mode ('r' or 'w') and return a file identifier FID. |
---|
5 | % File is opened in text mode: no effect on Unix but useful on Windows. |
---|
6 | |
---|
7 | % Copyright (C) 2004 Guillaume Flandin <Guillaume@artefact.tk> |
---|
8 | % $Revision: 1.1 $Date: 2004/05/05 17:14:09 $ |
---|
9 | |
---|
10 | [fid, errmsg] = fopen(filename,[permission 't']); |
---|
11 | if ~isempty(errmsg) |
---|
12 | switch permission |
---|
13 | case 'r' |
---|
14 | error(sprintf('Cannot open %s in read mode.',filename)); |
---|
15 | case 'w' |
---|
16 | error(sprintf('Cannot open %s in write mode.',filename)); |
---|
17 | otherwise |
---|
18 | error(errmsg); |
---|
19 | end |
---|
20 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.