# PetscFileMode
Access mode for a file. 
## Synopsis
```
typedef enum {
  FILE_MODE_UNDEFINED = -1,
  FILE_MODE_READ      = 0,
  FILE_MODE_WRITE,
  FILE_MODE_APPEND,
  FILE_MODE_UPDATE,
  FILE_MODE_APPEND_UPDATE
} PetscFileMode;
```


```none
`FILE_MODE_UNDEFINED` - initial invalid value
```
```none
`FILE_MODE_READ` - open a file at its beginning for reading
```
```none
`FILE_MODE_WRITE` - open a file at its beginning for writing (will create if the file does not exist)
```
```none
`FILE_MODE_APPEND` - open a file at end for writing
```
```none
`FILE_MODE_UPDATE` - open a file for updating, meaning for reading and writing
```
```none
`FILE_MODE_APPEND_UPDATE` - open a file for updating, meaning for reading and writing, at the end
```


## See Also
 `PetscViewerFileSetMode()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscsystypes.h.html#PetscFileMode">include/petscsystypes.h</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/viewer/tutorials/ex1.c.html">src/sys/classes/viewer/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/classes/viewer/tutorials/ex1f90.F90.html">src/sys/classes/viewer/tutorials/ex1f90.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/tutorials/ex5.c.html">src/sys/tutorials/ex5.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/tutorials/ex5f90.F90.html">src/sys/tutorials/ex5f90.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex10.c.html">src/vec/vec/tutorials/ex10.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex19.c.html">src/vec/vec/tutorials/ex19.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex5.c.html">src/vec/vec/tutorials/ex5.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex5f.F90.html">src/vec/vec/tutorials/ex5f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex6.c.html">src/vec/vec/tutorials/ex6.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/vec/tutorials/ex6f.F90.html">src/vec/vec/tutorials/ex6f.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex1.c.html">src/mat/tutorials/ex1.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscsystypes.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
