Create a file: Difference between revisions
Content added Content deleted
(corrected sorting of dc) |
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
||
Line 16: | Line 16: | ||
echos > \output.txt |
echos > \output.txt |
||
mkdir \docs</lang> |
mkdir \docs</lang> |
||
=={{header|AArch64 Assembly}}== |
=={{header|AArch64 Assembly}}== |
||
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
{{works with|as|Raspberry Pi 3B version Buster 64 bits}} |
||
Line 130: | Line 131: | ||
</lang> |
</lang> |
||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
Notes: |
Notes: |
||
Line 567: | Line 569: | ||
(for creation in the filesystem root, replace the filenames by "/output.txt" and "/docs") |
(for creation in the filesystem root, replace the filenames by "/output.txt" and "/docs") |
||
=={{header| |
=={{header|C sharp|C#}}== |
||
This creates a file in root: |
|||
<lang |
<lang csharp>using System; |
||
using System.IO; |
|||
FileIO text; |
|||
text.open("output.txt", FileIO.WRITE); |
|||
class Program { |
|||
</lang> |
|||
static void Main(string[] args) { |
|||
File.Create("output.txt"); |
|||
File.Create(@"\output.txt"); |
|||
Directory.CreateDirectory("docs"); |
|||
Directory.CreateDirectory(@"\docs"); |
|||
} |
|||
}</lang> |
|||
=={{header|C++}}== |
=={{header|C++}}== |
||
Line 591: | Line 601: | ||
}</lang> |
}</lang> |
||
=={{header| |
=={{header|ChucK}}== |
||
This creates a file in root: |
|||
<lang |
<lang c> |
||
FileIO text; |
|||
using System.IO; |
|||
text.open("output.txt", FileIO.WRITE); |
|||
</lang> |
|||
class Program { |
|||
static void Main(string[] args) { |
|||
File.Create("output.txt"); |
|||
File.Create(@"\output.txt"); |
|||
Directory.CreateDirectory("docs"); |
|||
Directory.CreateDirectory(@"\docs"); |
|||
} |
|||
}</lang> |
|||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
Line 767: | Line 769: | ||
=={{header|Dc}}== |
=={{header|Dc}}== |
||
<lang dc>! for d in . / ;do > "$d/output.txt" ; mkdir "$d/docs" ;done</lang> |
<lang dc>! for d in . / ;do > "$d/output.txt" ; mkdir "$d/docs" ;done</lang> |
||
=={{header|DCL}}== |
|||
<lang DCL>open/write output_file output.txt |
|||
open/write output_file [000000]output.txt |
|||
create/directory [.docs] |
|||
create/directory [000000.docs]</lang> |
|||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
Line 876: | Line 884: | ||
</lang> |
</lang> |
||
=={{header|DCL}}== |
|||
<lang DCL>open/write output_file output.txt |
|||
open/write output_file [000000]output.txt |
|||
create/directory [.docs] |
|||
create/directory [000000.docs]</lang> |
|||
=={{header|E}}== |
=={{header|E}}== |
||
Line 936: | Line 938: | ||
(cd "~/") |
(cd "~/") |
||
(shell-command "touch output.txt & mkdir docs")</lang> |
(shell-command "touch output.txt & mkdir docs")</lang> |
||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
Line 1,280: | Line 1,281: | ||
=={{header|LabVIEW}}== |
=={{header|LabVIEW}}== |
||
{{VI solution|LabVIEW_Create_a_file.png}} |
{{VI solution|LabVIEW_Create_a_file.png}} |
||
=={{header|Lasso}}== |
=={{header|Lasso}}== |
||
Line 1,300: | Line 1,300: | ||
local(d = dir('//docs')) |
local(d = dir('//docs')) |
||
#d->create</lang> |
#d->create</lang> |
||
=={{header|LFE}}== |
|||
<lang lisp> |
|||
(: file write_file '"output.txt" '"Some data") |
|||
(: file make_dir '"docs") |
|||
(: file write_file '"/output.txt" '"Some data") |
|||
(: file make_dir '"/docs") |
|||
</lang> |
|||
=={{header|Liberty BASIC}}== |
|||
Filenames without drive and directory info. refer to the same directory as the LB program is running from. |
|||
<br> |
|||
Full pathnames including drive name and directory can be used- back-slash separated. |
|||
<lang lb> |
|||
nomainwin |
|||
open "output.txt" for output as #f |
|||
close #f |
|||
result = mkdir( "F:\RC") |
|||
if result <>0 then notice "Directory not created!": end |
|||
open "F:\RC\output.txt" for output as #f |
|||
close #f |
|||
end |
|||
</lang> |
|||
=={{header|Lingo}}== |
=={{header|Lingo}}== |
||
Line 1,324: | Line 1,352: | ||
shell_cmd("mkdir /Docs") -- mac</lang> |
shell_cmd("mkdir /Docs") -- mac</lang> |
||
=={{header|Liberty BASIC}}== |
|||
Filenames without drive and directory info. refer to the same directory as the LB program is running from. |
|||
<br> |
|||
Full pathnames including drive name and directory can be used- back-slash separated. |
|||
<lang lb> |
|||
nomainwin |
|||
open "output.txt" for output as #f |
|||
close #f |
|||
result = mkdir( "F:\RC") |
|||
if result <>0 then notice "Directory not created!": end |
|||
open "F:\RC\output.txt" for output as #f |
|||
close #f |
|||
end |
|||
</lang> |
|||
=={{header|Little}}== |
=={{header|Little}}== |
||
We are going to use /tmp instead the root. |
We are going to use /tmp instead the root. |
||
Line 1,375: | Line 1,385: | ||
create_dir("docs"); |
create_dir("docs"); |
||
create_dir("/tmp/docs");</lang> |
create_dir("/tmp/docs");</lang> |
||
=={{header|LFE}}== |
|||
<lang lisp> |
|||
(: file write_file '"output.txt" '"Some data") |
|||
(: file make_dir '"docs") |
|||
(: file write_file '"/output.txt" '"Some data") |
|||
(: file make_dir '"/docs") |
|||
</lang> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
Line 1,487: | Line 1,488: | ||
:lisp (mapcar #'ensure-directories-exist '("docs/" "/docs/"))</lang> |
:lisp (mapcar #'ensure-directories-exist '("docs/" "/docs/"))</lang> |
||
=={{header|MAXScript}}== |
=={{header|MAXScript}}== |
||
Line 1,655: | Line 1,655: | ||
open(directory & "output.txt", fmWrite).close() |
open(directory & "output.txt", fmWrite).close() |
||
createDir(directory & "docs")</lang> |
createDir(directory & "docs")</lang> |
||
=={{header|Objective-C}}== |
|||
<lang objc>NSFileManager *fm = [NSFileManager defaultManager]; |
|||
[fm createFileAtPath:@"output.txt" contents:[NSData data] attributes:nil]; |
|||
// Pre-OS X 10.5 |
|||
[fm createDirectoryAtPath:@"docs" attributes:nil]; |
|||
// OS X 10.5+ |
|||
[fm createDirectoryAtPath:@"docs" withIntermediateDirectories:NO attributes:nil error:NULL];</lang> |
|||
=={{header|Objeck}}== |
=={{header|Objeck}}== |
||
Line 1,685: | Line 1,675: | ||
} |
} |
||
</lang> |
</lang> |
||
=={{header|Objective-C}}== |
|||
<lang objc>NSFileManager *fm = [NSFileManager defaultManager]; |
|||
[fm createFileAtPath:@"output.txt" contents:[NSData data] attributes:nil]; |
|||
// Pre-OS X 10.5 |
|||
[fm createDirectoryAtPath:@"docs" attributes:nil]; |
|||
// OS X 10.5+ |
|||
[fm createDirectoryAtPath:@"docs" withIntermediateDirectories:NO attributes:nil error:NULL];</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |
||
Line 1,704: | Line 1,704: | ||
{OS.mkDir Dir#"docs" ['S_IRUSR' 'S_IWUSR' 'S_IXUSR' 'S_IXGRP']} |
{OS.mkDir Dir#"docs" ['S_IRUSR' 'S_IWUSR' 'S_IXUSR' 'S_IXGRP']} |
||
end</lang> |
end</lang> |
||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
Line 1,767: | Line 1,766: | ||
<lang perl>unlink $_ for qw(/docs/output.txt ./docs/output.txt); |
<lang perl>unlink $_ for qw(/docs/output.txt ./docs/output.txt); |
||
rmdir $_ for qw(/docs ./docs);</lang> |
rmdir $_ for qw(/docs ./docs);</lang> |
||
=={{header|Perl 6}}== |
|||
<lang perl6> |
|||
for '.', '' -> $prefix { |
|||
mkdir "$prefix/docs"; |
|||
open "$prefix/output.txt", :w; |
|||
} |
|||
</lang> |
|||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Line 1,878: | Line 1,869: | ||
(display-to-file "" "/output.txt") |
(display-to-file "" "/output.txt") |
||
(make-directory "/docs")</lang> |
(make-directory "/docs")</lang> |
||
=={{header|Raku}}== |
|||
(formerly Perl 6) |
|||
<lang perl6> |
|||
for '.', '' -> $prefix { |
|||
mkdir "$prefix/docs"; |
|||
open "$prefix/output.txt", :w; |
|||
} |
|||
</lang> |
|||
=={{header|Raven}}== |
=={{header|Raven}}== |
||
Line 1,916: | Line 1,916: | ||
end /*2*/ /*now, go and perform them again.*/ |
end /*2*/ /*now, go and perform them again.*/ |
||
/*stick a fork in it, we're done.*/</lang> |
/*stick a fork in it, we're done.*/</lang> |
||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
Line 1,931: | Line 1,930: | ||
File.open(dir + 'output.txt', 'w') {} # create empty file /output.txt, then ./output.txt |
File.open(dir + 'output.txt', 'w') {} # create empty file /output.txt, then ./output.txt |
||
}</lang> |
}</lang> |
||
=={{header|Run BASIC}}== |
=={{header|Run BASIC}}== |
||
<lang RunBasic>open "output.txt" for output as #f |
<lang RunBasic>open "output.txt" for output as #f |
||
Line 1,940: | Line 1,940: | ||
open "f:\doc\output.txt" for output as #f |
open "f:\doc\output.txt" for output as #f |
||
close #f</lang> |
close #f</lang> |
||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
<lang rust>use std::io::{self, Write}; |
<lang rust>use std::io::{self, Write}; |
||
Line 2,076: | Line 2,077: | ||
host(1,'mkdir /docs') |
host(1,'mkdir /docs') |
||
end</lang> |
end</lang> |
||
=={{header|SQLite}}== |
|||
<lang sqlite3> |
|||
/* |
|||
*Use '/' for *nix. Use whatever your root directory is on Windows. |
|||
*Must be run as admin. |
|||
*/ |
|||
.shell mkdir "docs"; |
|||
.shell mkdir "/docs"; |
|||
.output output.txt |
|||
.output /output.txt |
|||
</lang> |
|||
=={{header|SQL PL}}== |
=={{header|SQL PL}}== |
||
Line 2,133: | Line 2,122: | ||
output.txt |
output.txt |
||
</pre> |
</pre> |
||
=={{header|SQLite}}== |
|||
<lang sqlite3> |
|||
/* |
|||
*Use '/' for *nix. Use whatever your root directory is on Windows. |
|||
*Must be run as admin. |
|||
*/ |
|||
.shell mkdir "docs"; |
|||
.shell mkdir "/docs"; |
|||
.output output.txt |
|||
.output /output.txt |
|||
</lang> |
|||
=={{header|Standard ML}}== |
=={{header|Standard ML}}== |
||
Line 2,175: | Line 2,176: | ||
" docs" &777 mkdir |
" docs" &777 mkdir |
||
" /docs" &777 mkdir</lang> |
" /docs" &777 mkdir</lang> |
||
=={{header|TUSCRIPT}}== |
=={{header|TUSCRIPT}}== |
||
<lang tuscript> |
<lang tuscript> |
||
Line 2,183: | Line 2,185: | ||
ERROR/STOP CREATE ("docs",project,-std-) |
ERROR/STOP CREATE ("docs",project,-std-) |
||
</lang> |
</lang> |
||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
Line 2,206: | Line 2,209: | ||
f.createdir "/docs" |
f.createdir "/docs" |
||
</lang> |
</lang> |
||
=={{header|VBA}}== |
=={{header|VBA}}== |
||
<lang vb>Public Sub create_file() |
<lang vb>Public Sub create_file() |
||
Line 2,217: | Line 2,221: | ||
Close #FreeFile |
Close #FreeFile |
||
End Sub</lang> |
End Sub</lang> |
||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
<lang vb> |
<lang vb> |
||
Line 2,257: | Line 2,262: | ||
IO.File.Create(IO.Path.DirectorySeparatorChar & "output.txt").Close()</lang> |
IO.File.Create(IO.Path.DirectorySeparatorChar & "output.txt").Close()</lang> |
||
=={{header|Visual Objects}}== |
|||
//Use Library System Library |
|||
<lang visualfoxpro> |
|||
DirMake(String2Psz("c:\docs")) |
|||
FCreate("c:\docs\output.txt", FC_NORMAL) |
|||
</lang> |
|||
{{omit from|SmileBASIC|Filesystem has no directories, only projects which cannot be manipulated by code.}} |
|||
=={{header|X86 Assembly}}== |
=={{header|X86 Assembly}}== |
||
Line 2,345: | Line 2,358: | ||
<lang zxbasic>SAVE "OUTPUT" CODE 16384,0</lang> |
<lang zxbasic>SAVE "OUTPUT" CODE 16384,0</lang> |
||
=={{header|Visual Objects}}== |
|||
//Use Library System Library |
|||
<lang visualfoxpro> |
|||
DirMake(String2Psz("c:\docs")) |
|||
FCreate("c:\docs\output.txt", FC_NORMAL) |
|||
</lang> |
|||
{{omit from|SmileBASIC|Filesystem has no directories, only projects which cannot be manipulated by code.}} |